Skip to content

Commit

Permalink
🍺 add locale
Browse files Browse the repository at this point in the history
  • Loading branch information
akameco committed Sep 4, 2016
1 parent 38cf4f0 commit 1527297
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 29 deletions.
6 changes: 3 additions & 3 deletions app/components/modal/select-column-modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, {Component} from 'react';
import css from 'react-css-modules';
import {RANKING_MODES} from '../../contains';
import type {Query} from '../../types/column';
import {rankMap} from '../../utils';
import locale from '../../locale/';
import styles from './select-column-modal.css';

class Link extends Component {
Expand All @@ -20,7 +20,7 @@ class Link extends Component {
return (
<li>
<a onClick={() => this.props.onSelect(this.props.mode)}>
{rankMap(this.props.mode)}
{locale(`ranking.${this.props.mode}`)}
</a>
</li>
);
Expand All @@ -37,7 +37,7 @@ export default class SelectColumnModal extends Component {
props: Props;

handleAddRanking = (mode: string) => {
this.props.onSelect({type: 'ranking', opts: {mode, page: 1}}, `${rankMap(mode)}ランキング`);
this.props.onSelect({type: 'ranking', opts: {mode, page: 1}}, `${locale(`ranking.${mode}`)}ランキング`);
}

handleAddFavorite = (publicity: 'private' | 'public') => {
Expand Down
24 changes: 24 additions & 0 deletions app/locale/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// @flow
/* eslint-disable camelcase */
import dotProp from 'dot-prop';

const obj = {
ranking: {
daily: 'デイリー',
weekly: 'ウィークリー',
monthly: 'マンスリー',
rookie: 'ルーキー',
original: 'オリジナル',
male: '男子に人気',
female: '女子に人気',
daily_r18: 'R18 デイリー',
weekly_r18: 'R18 ウィークリー',
male_r18: 'R18 男子に人気',
female_r18: 'R18 女子に人気',
r18g: 'R18 G'
}
};

export default (str: string) => {
return dotProp.get(obj, str);
};
19 changes: 0 additions & 19 deletions app/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
// @flow
/* eslint-disable camelcase */
export const rankMap = (mode: string) => {
return {
daily: 'デイリー',
weekly: 'ウィークリー',
monthly: 'マンスリー',
rookie: 'ルーキー',
original: 'オリジナル',
male: '男子に人気',
female: '女子に人気',
daily_r18: 'R18 デイリー',
weekly_r18: 'R18 ウィークリー',
male_r18: 'R18 男子に人気',
female_r18: 'R18 女子に人気',
r18g: 'R18 G'
}[mode];
};
/* eslint-enable camelcase */

export function delay(ms: number) {
return new Promise(resolve => {
setTimeout(() => resolve(true), ms);
Expand Down
12 changes: 12 additions & 0 deletions interface/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,15 @@ declare module 'electron-config' {
declare module 'electron-debug' {
declare var exports: any;
}

declare module 'dot-prop' {
declare var exports: any;
}

declare module 'electron-dl' {
declare var exports: any;
}

declare module 'pixiv-app-api' {
declare var exports: any;
}
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "PixivDeck",
"productName": "PixivDeck",
"version": "0.2.0",
"version": "0.3.0",
"description": "pixiv client for desktop",
"main": "main.js",
"scripts": {
Expand Down Expand Up @@ -30,6 +30,7 @@
"dependencies": {
"autolinker": "^0.28.0",
"babel-polyfill": "^6.13.0",
"dot-prop": "^3.0.0",
"electron-config": "^0.2.1",
"electron-context-menu": "^0.4.0",
"electron-debug": "^1.0.1",
Expand All @@ -39,14 +40,15 @@
"lodash.merge": "^4.6.0",
"lodash.union": "^4.6.0",
"normalizr": "^2.2.1",
"pixiv-app-api": "^0.1.1",
"pixiv.js": "^0.17.2",
"pixiv-app-api": "^0.2.0",
"pixiv.js": "^0.18.0",
"react": "^15.3.1",
"react-css-modules": "^3.7.10",
"react-dom": "^15.3.1",
"react-redux": "^4.4.5",
"react-sortable-pane": "^0.5.4",
"redux": "^3.5.2"
"redux": "^3.5.2",
"wallpaper": "^2.3.0"
},
"devDependencies": {
"babel-core": "^6.14.0",
Expand All @@ -64,7 +66,7 @@
"cross-env": "^2.0.1",
"css-loader": "^0.24.0",
"del": "^2.2.2",
"electron": "^1.3.4",
"electron": "^1.3.5",
"electron-devtools-installer": "^2.0.1",
"electron-packager": "^7.7.0",
"eslint": "^3.4.0",
Expand All @@ -78,7 +80,7 @@
"redux-logger": "^2.6.1",
"style-loader": "^0.13.1",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.15.0",
"webpack-dev-server": "^1.15.1",
"webpack-merge": "^0.14.1",
"xo": "^0.16.0"
},
Expand Down
4 changes: 3 additions & 1 deletion webpack.config.electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ module.exports = merge(baseConfig, {

externals: [
'electron-config',
'electron-referer',
'electron-context-menu',
'pixiv.js',
'pixiv-app-api',
'electron-dl'
'electron-dl',
'dot-prop'
]
});

0 comments on commit 1527297

Please sign in to comment.