From b03ccead4bfaee29ef00e0e68b83d60f5be2c853 Mon Sep 17 00:00:00 2001 From: syuilo <Syuilotan@yahoo.co.jp> Date: Wed, 16 May 2018 08:01:55 +0900 Subject: [PATCH 01/14] Update Crowdin configuration file --- crowdin.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 crowdin.yml diff --git a/crowdin.yml b/crowdin.yml new file mode 100644 index 0000000000..3f8dfdeca8 --- /dev/null +++ b/crowdin.yml @@ -0,0 +1,3 @@ +files: + - source: /locales/ja.yml + translation: /locales/%two_letters_code%.yml From eb5543aae3c987cbb41c82fecbc6a2ad091e5ea1 Mon Sep 17 00:00:00 2001 From: syuilo <Syuilotan@yahoo.co.jp> Date: Wed, 16 May 2018 08:10:01 +0900 Subject: [PATCH 02/14] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b18be325f4..0cb3233d4a 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,9 @@ please see [Setup and installation guide](./docs/setup.en.md). ---------------------------------------------------------------- **[PR](https://github.com/syuilo/misskey/pulls)s welcome!** -If you want to translate Misskey, please see [Translation guide](./docs/translate.en.md). +If you want to... +* i18n ... please see [Translation guide](./docs/translate.en.md). +* l10n ... please visit https://crowdin.com/project/misskey :heart: Backers & Sponsors ---------------------------------------------------------------- From 4e0f34ce1d07d991eda6d9bf8aa961c7664dac5e Mon Sep 17 00:00:00 2001 From: syuilo <Syuilotan@yahoo.co.jp> Date: Wed, 16 May 2018 08:16:40 +0900 Subject: [PATCH 03/14] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0cb3233d4a..a44c7e16ee 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ ultimately sophisticated new type of mini-blog based SNS. * Real time contents * ActivityPub compatible -and more! You can touch with your own eyes at https://misskey.xyz/. +and more! You can touch with your own eyes at [misskey.xyz](https://misskey.xyz). :package: Create your instance ---------------------------------------------------------------- From e127341228ebc8817f5a7a3458bc600c64224811 Mon Sep 17 00:00:00 2001 From: syuilo <syuilotan@yahoo.co.jp> Date: Wed, 16 May 2018 08:22:07 +0900 Subject: [PATCH 04/14] i18n --- locales/en.yml | 5 +++++ locales/ja.yml | 6 ++++++ src/client/app/desktop/views/components/timeline.vue | 8 ++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/locales/en.yml b/locales/en.yml index b664b2a9a9..9ffd232cb6 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -320,6 +320,11 @@ desktop/views/components/settings.profile.vue: description: "Description" birthday: "Birthday" save: "Update profile" +desktop/views/components/timeline.vue: + home: "Home" + local: "Local" + global: "Global" + list: "List" desktop/views/components/ui.header.account.vue: profile: "Your profile" drive: "Drive" diff --git a/locales/ja.yml b/locales/ja.yml index e13348c407..85826110f0 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -366,6 +366,12 @@ desktop/views/components/settings.profile.vue: birthday: "誕生日" save: "保存" +desktop/views/components/timeline.vue: + home: "ホーム" + local: "ローカル" + global: "グローバル" + list: "リスト" + desktop/views/components/ui.header.account.vue: profile: "プロフィール" drive: "ドライブ" diff --git a/src/client/app/desktop/views/components/timeline.vue b/src/client/app/desktop/views/components/timeline.vue index 855d032586..a776e40a24 100644 --- a/src/client/app/desktop/views/components/timeline.vue +++ b/src/client/app/desktop/views/components/timeline.vue @@ -1,11 +1,11 @@ <template> <div class="mk-timeline"> <header> - <span :data-active="src == 'home'" @click="src = 'home'">%fa:home% ホーム</span> - <span :data-active="src == 'local'" @click="src = 'local'">%fa:R comments% ローカル</span> - <span :data-active="src == 'global'" @click="src = 'global'">%fa:globe% グローバル</span> + <span :data-active="src == 'home'" @click="src = 'home'">%fa:home% %i18n:@home%</span> + <span :data-active="src == 'local'" @click="src = 'local'">%fa:R comments% %i18n:@local%</span> + <span :data-active="src == 'global'" @click="src = 'global'">%fa:globe% %i18n:@global%</span> <span :data-active="src == 'list'" @click="src = 'list'" v-if="list">%fa:list% {{ list.title }}</span> - <button @click="chooseList" title="リスト">%fa:list%</button> + <button @click="chooseList" title="%i18n:@list%">%fa:list%</button> </header> <x-core v-if="src == 'home'" ref="tl" key="home" src="home"/> <x-core v-if="src == 'local'" ref="tl" key="local" src="local"/> From f59209aaa31195dda40fee870207d42a0ea93df8 Mon Sep 17 00:00:00 2001 From: syuilo <syuilotan@yahoo.co.jp> Date: Wed, 16 May 2018 16:50:36 +0900 Subject: [PATCH 05/14] Fix bug --- src/remote/activitypub/models/person.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/remote/activitypub/models/person.ts b/src/remote/activitypub/models/person.ts index be035097b9..20e594ff1d 100644 --- a/src/remote/activitypub/models/person.ts +++ b/src/remote/activitypub/models/person.ts @@ -49,6 +49,7 @@ export async function createPerson(value: any, resolver?: Resolver): Promise<IUs object == null || object.type !== 'Person' || typeof object.preferredUsername !== 'string' || + typeof object.inbox !== 'string' || !validateUsername(object.preferredUsername) || !isValidName(object.name == '' ? null : object.name) ) { From 34186cf45fef455e5a5361831107c5c7a11b8d80 Mon Sep 17 00:00:00 2001 From: syuilo <syuilotan@yahoo.co.jp> Date: Wed, 16 May 2018 17:04:39 +0900 Subject: [PATCH 06/14] :v: --- src/models/user.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/user.ts b/src/models/user.ts index 352819f618..af03faf847 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -114,7 +114,7 @@ export function validatePassword(password: string): boolean { } export function isValidName(name?: string): boolean { - return name === null || (typeof name == 'string' && name.length < 30 && name.trim() != ''); + return name === null || (typeof name == 'string' && name.length < 50 && name.trim() != ''); } export function isValidDescription(description: string): boolean { From 66437f31c09f2257e6f683237b71e13d80fa4b50 Mon Sep 17 00:00:00 2001 From: syuilo <syuilotan@yahoo.co.jp> Date: Wed, 16 May 2018 17:06:12 +0900 Subject: [PATCH 07/14] Save remote user's endpoints --- src/models/user.ts | 1 + src/remote/activitypub/models/person.ts | 4 +++- src/remote/activitypub/type.ts | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/models/user.ts b/src/models/user.ts index af03faf847..108111ceca 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -87,6 +87,7 @@ export interface ILocalUser extends IUserBase { export interface IRemoteUser extends IUserBase { inbox: string; + endpoints: string[]; uri: string; url?: string; publicKey: { diff --git a/src/remote/activitypub/models/person.ts b/src/remote/activitypub/models/person.ts index 20e594ff1d..33280f3d89 100644 --- a/src/remote/activitypub/models/person.ts +++ b/src/remote/activitypub/models/person.ts @@ -101,6 +101,7 @@ export async function createPerson(value: any, resolver?: Resolver): Promise<IUs publicKeyPem: person.publicKey.publicKeyPem }, inbox: person.inbox, + endpoints: person.endpoints, uri: person.id, url: person.url }) as IRemoteUser; @@ -208,7 +209,8 @@ export async function updatePerson(value: string | IObject, resolver?: Resolver) followingCount, notesCount, name: person.name, - url: person.url + url: person.url, + endpoints: person.endpoints } }); } diff --git a/src/remote/activitypub/type.ts b/src/remote/activitypub/type.ts index 10b29fe607..ca38ec2227 100644 --- a/src/remote/activitypub/type.ts +++ b/src/remote/activitypub/type.ts @@ -50,6 +50,7 @@ export interface IPerson extends IObject { followers: any; following: any; outbox: any; + endpoints: string[]; } export const isCollection = (object: IObject): object is ICollection => From 161bce1a426fe426e2e18d191d2acdfc309e8d7c Mon Sep 17 00:00:00 2001 From: syuilo <Syuilotan@yahoo.co.jp> Date: Wed, 16 May 2018 17:30:00 +0900 Subject: [PATCH 08/14] Update deliver.ts --- src/queue/processors/http/deliver.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/queue/processors/http/deliver.ts b/src/queue/processors/http/deliver.ts index 6810fa4d91..2c4bbe9bf0 100644 --- a/src/queue/processors/http/deliver.ts +++ b/src/queue/processors/http/deliver.ts @@ -14,7 +14,7 @@ export default async (job: kue.Job, done): Promise<void> => { done(); } else { console.warn(`deliver failed: ${res.statusMessage}`); - done(res); + done(res.statusMessage); } } }; From f9cd25c4240d5fed8c205dcdddbe0d0c21d31a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Miko=C5=82ajczak?= <me@m4sk.in> Date: Wed, 16 May 2018 16:35:07 +0200 Subject: [PATCH 09/14] fix typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Mikołajczak <me@m4sk.in> --- locales/de.yml | 2 +- locales/en.yml | 2 +- locales/es.yml | 2 +- locales/fr.yml | 2 +- locales/it.yml | 2 +- locales/ja.yml | 2 +- locales/ko.yml | 2 +- locales/pl.yml | 2 +- locales/ru.yml | 2 +- locales/zh.yml | 2 +- src/client/app/desktop/views/components/calendar.vue | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/locales/de.yml b/locales/de.yml index b6e7898a8e..c3f9d685ae 100644 --- a/locales/de.yml +++ b/locales/de.yml @@ -19,7 +19,7 @@ common: wednesday: "水" thursday: "木" friday: "金" - satruday: "土" + saturday: "土" reactions: like: "いいね" love: "しゅき" diff --git a/locales/en.yml b/locales/en.yml index 78571918d3..43bcbeeb64 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -19,7 +19,7 @@ common: wednesday: "W" thursday: "T" friday: "F" - satruday: "S" + saturday: "S" reactions: like: "Like" love: "Love" diff --git a/locales/es.yml b/locales/es.yml index b6e7898a8e..c3f9d685ae 100644 --- a/locales/es.yml +++ b/locales/es.yml @@ -19,7 +19,7 @@ common: wednesday: "水" thursday: "木" friday: "金" - satruday: "土" + saturday: "土" reactions: like: "いいね" love: "しゅき" diff --git a/locales/fr.yml b/locales/fr.yml index 9978407abd..33d8ea5b4e 100644 --- a/locales/fr.yml +++ b/locales/fr.yml @@ -19,7 +19,7 @@ common: wednesday: "M" thursday: "J" friday: "V" - satruday: "S" + saturday: "S" reactions: like: "Aime" love: "Adore" diff --git a/locales/it.yml b/locales/it.yml index b6e7898a8e..c3f9d685ae 100644 --- a/locales/it.yml +++ b/locales/it.yml @@ -19,7 +19,7 @@ common: wednesday: "水" thursday: "木" friday: "金" - satruday: "土" + saturday: "土" reactions: like: "いいね" love: "しゅき" diff --git a/locales/ja.yml b/locales/ja.yml index 85826110f0..d8e15fb3c0 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -20,7 +20,7 @@ common: wednesday: "水" thursday: "木" friday: "金" - satruday: "土" + saturday: "土" reactions: like: "いいね" diff --git a/locales/ko.yml b/locales/ko.yml index b6e7898a8e..c3f9d685ae 100644 --- a/locales/ko.yml +++ b/locales/ko.yml @@ -19,7 +19,7 @@ common: wednesday: "水" thursday: "木" friday: "金" - satruday: "土" + saturday: "土" reactions: like: "いいね" love: "しゅき" diff --git a/locales/pl.yml b/locales/pl.yml index 3474a7355a..aaaf20deef 100644 --- a/locales/pl.yml +++ b/locales/pl.yml @@ -19,7 +19,7 @@ common: wednesday: "Ś" thursday: "C" friday: "P" - satruday: "S" + saturday: "S" reactions: like: "Lubię" love: "Kocham" diff --git a/locales/ru.yml b/locales/ru.yml index b6e7898a8e..c3f9d685ae 100644 --- a/locales/ru.yml +++ b/locales/ru.yml @@ -19,7 +19,7 @@ common: wednesday: "水" thursday: "木" friday: "金" - satruday: "土" + saturday: "土" reactions: like: "いいね" love: "しゅき" diff --git a/locales/zh.yml b/locales/zh.yml index b6e7898a8e..c3f9d685ae 100644 --- a/locales/zh.yml +++ b/locales/zh.yml @@ -19,7 +19,7 @@ common: wednesday: "水" thursday: "木" friday: "金" - satruday: "土" + saturday: "土" reactions: like: "いいね" love: "しゅき" diff --git a/src/client/app/desktop/views/components/calendar.vue b/src/client/app/desktop/views/components/calendar.vue index 1d8cc4f3a9..757eefac7e 100644 --- a/src/client/app/desktop/views/components/calendar.vue +++ b/src/client/app/desktop/views/components/calendar.vue @@ -64,7 +64,7 @@ export default Vue.extend({ '%i18n:!common.weekday-short.wednesday%', '%i18n:!common.weekday-short.thursday%', '%i18n:!common.weekday-short.friday%', - '%i18n:!common.weekday-short.satruday%' + '%i18n:!common.weekday-short.saturday%' ] }; }, From 1d49cb475dab4522623e0ca2837851b981f3a971 Mon Sep 17 00:00:00 2001 From: rinsuki <428rinsuki+git@gmail.com> Date: Thu, 17 May 2018 07:49:43 +0900 Subject: [PATCH 10/14] add yarn.lock to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index be8689e2ed..2568aa11c2 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ run.bat api-docs.json package-lock.json version.json +yarn.lock From 859c0c3491b319107161175942725b7a50dbf685 Mon Sep 17 00:00:00 2001 From: rinsuki <428rinsuki+git@gmail.com> Date: Thu, 17 May 2018 08:14:30 +0900 Subject: [PATCH 11/14] fix #1428 --- src/text/html.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/text/html.ts b/src/text/html.ts index f33ef4997b..40f86e4b2b 100644 --- a/src/text/html.ts +++ b/src/text/html.ts @@ -1,5 +1,6 @@ import { lib as emojilib } from 'emojilib'; import { JSDOM } from 'jsdom'; +import config from '../config'; const handlers = { bold({ document }, { bold }) { @@ -43,7 +44,7 @@ const handlers = { mention({ document }, { content }) { const a = document.createElement('a'); - a.href = '/' + content; + a.href = `${config.url}/${content}`; a.textContent = content; document.body.appendChild(a); }, From 14f7ff13ec13e282480e1be779dc25f080cf5f4c Mon Sep 17 00:00:00 2001 From: syuilo <syuilotan@yahoo.co.jp> Date: Thu, 17 May 2018 09:28:31 +0900 Subject: [PATCH 12/14] #491 --- locales/index.ts | 2 +- src/build/i18n.ts | 17 +- webpack.config.ts | 393 +++++++++++++++++++++++----------------------- webpack/i18n.ts | 24 +++ 4 files changed, 229 insertions(+), 207 deletions(-) create mode 100644 webpack/i18n.ts diff --git a/locales/index.ts b/locales/index.ts index 926844766d..89d18190f6 100644 --- a/locales/index.ts +++ b/locales/index.ts @@ -14,7 +14,7 @@ const langs = { 'en': loadLang('en'), 'fr': loadLang('fr'), 'ja': native, - 'pl': loadLang('pl') + 'pl': loadLang('pl') }; Object.entries(langs).map(([, locale]) => { diff --git a/src/build/i18n.ts b/src/build/i18n.ts index 6c0f633ad9..212a5837dd 100644 --- a/src/build/i18n.ts +++ b/src/build/i18n.ts @@ -7,7 +7,7 @@ import locale from '../../locales'; export default class Replacer { private lang: string; - public pattern = /%i18n:([a-z0-9_\-@\.\!]+?)%/g; + public pattern = /%i18n:([a-z0-9_\-\.\!]+?)%/g; constructor(lang: string) { this.lang = lang; @@ -53,23 +53,20 @@ export default class Replacer { } } - public replacement(ctx, match, key) { - const client = '/src/client/app/'; - let name = null; + public replacement(match, key) { + let path = null; const shouldEscape = key[0] == '!'; if (shouldEscape) { key = key.substr(1); } - if (key[0] == '@') { - name = ctx.src.substr(ctx.src.indexOf(client) + client.length); - key = key.substr(1); + if (key.indexOf('|') != -1) { + path = key.split('|')[0]; + key = key.split('|')[1]; } - if (ctx && ctx.lang) this.lang = ctx.lang; - - const txt = this.get(name, key); + const txt = this.get(path, key); return shouldEscape ? txt.replace(/'/g, '\\x27').replace(/"/g, '\\x22') diff --git a/webpack.config.ts b/webpack.config.ts index 0e12fda633..3ac3c4e297 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -11,8 +11,10 @@ const minifyHtml = require('html-minifier').minify; const WebpackOnBuildPlugin = require('on-build-webpack'); //const HardSourceWebpackPlugin = require('hard-source-webpack-plugin'); const ProgressBarPlugin = require('progress-bar-webpack-plugin'); +const I18nPlugin = require('webpack-multilang-i18n-plugin'); import I18nReplacer from './src/build/i18n'; +import { pattern as i18nPattern, replacement as i18nReplacement } from './webpack/i18n'; import { pattern as faPattern, replacement as faReplacement } from './src/build/fa'; const constants = require('./src/const.json'); import config from './src/config'; @@ -37,183 +39,155 @@ global['collapseSpacesReplacement'] = html => { global['base64replacement'] = (_, key) => { return fs.readFileSync(__dirname + '/src/client/' + key, 'base64'); }; + +global['i18nReplacement'] = i18nReplacement; + //#endregion const langs = Object.keys(locales); -// 無圧縮スクリプトを用意するのは重いので一時的に無効化 -//const entries = process.env.NODE_ENV == 'production' -// ? langs.map(l => [l, false]).concat(langs.map(l => [l, true])) -// : langs.map(l => [l, false]); -const entries = process.env.NODE_ENV == 'production' - ? langs.map(l => [l, true]) - : langs.map(l => [l, false]); +const isProduction = process.env.NODE_ENV == 'production'; -module.exports = entries.map(x => { - const [lang, isProduction] = x; +// Entries +const entry = { + desktop: './src/client/app/desktop/script.ts', + mobile: './src/client/app/mobile/script.ts', + //stats: './src/client/app/stats/script.ts', + //status: './src/client/app/status/script.ts', + dev: './src/client/app/dev/script.ts', + auth: './src/client/app/auth/script.ts', + sw: './src/client/app/sw.js' +}; - // Chunk name - const name = lang; +const output = { + path: __dirname + '/built/client/assets', + filename: `[name].${version}.-.${isProduction ? 'min' : 'raw'}.js` +}; - // Entries - const entry = { - desktop: './src/client/app/desktop/script.ts', - mobile: './src/client/app/mobile/script.ts', - //ch: './src/client/app/ch/script.ts', - //stats: './src/client/app/stats/script.ts', - //status: './src/client/app/status/script.ts', - dev: './src/client/app/dev/script.ts', - auth: './src/client/app/auth/script.ts', - sw: './src/client/app/sw.js' - }; +//#region Define consts +const consts = { + _RECAPTCHA_SITEKEY_: config.recaptcha.site_key, + _SW_PUBLICKEY_: config.sw ? config.sw.public_key : null, + _THEME_COLOR_: constants.themeColor, + _COPYRIGHT_: constants.copyright, + _VERSION_: version, + _CODENAME_: codename, + _STATUS_URL_: config.status_url, + _STATS_URL_: config.stats_url, + _DOCS_URL_: config.docs_url, + _API_URL_: config.api_url, + _WS_URL_: config.ws_url, + _DEV_URL_: config.dev_url, + _LANG_: '%lang%', + _HOST_: config.host, + _HOSTNAME_: config.hostname, + _URL_: config.url, + _LICENSE_: licenseHtml, + _GOOGLE_MAPS_API_KEY_: config.google_maps_api_key +}; - const output = { - path: __dirname + '/built/client/assets', - filename: `[name].${version}.${lang}.${isProduction ? 'min' : 'raw'}.js` - }; +const _consts = {}; - const i18nReplacer = new I18nReplacer(lang as string); - global['i18nReplacement'] = i18nReplacer.replacement; +Object.keys(consts).forEach(key => { + _consts[key] = JSON.stringify(consts[key]); +}); +//#endregion - //#region Define consts - const consts = { - _RECAPTCHA_SITEKEY_: config.recaptcha.site_key, - _SW_PUBLICKEY_: config.sw ? config.sw.public_key : null, - _THEME_COLOR_: constants.themeColor, - _COPYRIGHT_: constants.copyright, - _VERSION_: version, - _CODENAME_: codename, - _STATUS_URL_: config.status_url, - _STATS_URL_: config.stats_url, - _DOCS_URL_: config.docs_url, - _API_URL_: config.api_url, - _WS_URL_: config.ws_url, - _DEV_URL_: config.dev_url, - _LANG_: lang, - _HOST_: config.host, - _HOSTNAME_: config.hostname, - _URL_: config.url, - _LICENSE_: licenseHtml, - _GOOGLE_MAPS_API_KEY_: config.google_maps_api_key - }; +const plugins = [ + //new HardSourceWebpackPlugin(), + new ProgressBarPlugin({ + format: chalk` {cyan.bold yes we can} {bold [}:bar{bold ]} {green.bold :percent} {gray (:current/:total)} :elapseds`, + clear: false + }), + new webpack.DefinePlugin(_consts), + new webpack.DefinePlugin({ + 'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development') + }), + new WebpackOnBuildPlugin(stats => { + fs.writeFileSync('./built/client/meta.json', JSON.stringify({ + version + }), 'utf-8'); - const _consts = {}; + //#region i18n + langs.forEach(lang => { + Object.keys(entry).forEach(file => { + let src = fs.readFileSync(`${__dirname}/built/client/assets/${file}.${version}.-.${isProduction ? 'min' : 'raw'}.js`, 'utf8'); - Object.keys(consts).forEach(key => { - _consts[key] = JSON.stringify(consts[key]); - }); - //#endregion + const i18nReplacer = new I18nReplacer(lang); - const plugins = [ - //new HardSourceWebpackPlugin(), - new ProgressBarPlugin({ - format: chalk` {cyan.bold yes we can} {bold [}:bar{bold ]} {green.bold :percent} {gray (:current/:total)} :elapseds`, - clear: false - }), - new webpack.DefinePlugin(_consts), - new webpack.DefinePlugin({ - 'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development') - }), - new WebpackOnBuildPlugin(stats => { - fs.writeFileSync('./built/client/meta.json', JSON.stringify({ - version - }), 'utf-8'); - }), - new VueLoaderPlugin() - ]; + src = src.replace(i18nReplacer.pattern, i18nReplacer.replacement); + src = src.replace('%lang%', lang); - if (isProduction) { - plugins.push(new webpack.optimize.ModuleConcatenationPlugin()); - } + fs.writeFileSync(`${__dirname}/built/client/assets/${file}.${version}.${lang}.${isProduction ? 'min' : 'raw'}.js`, src, 'utf8'); + }); + }); + //#endregion + }), + new VueLoaderPlugin(), + new I18nPlugin() +]; - return { - name, - entry, - module: { - rules: [{ - test: /\.vue$/, - exclude: /node_modules/, - use: [{ - loader: 'vue-loader', - options: { - cssSourceMap: false, - compilerOptions: { - preserveWhitespace: false - } +if (isProduction) { + plugins.push(new webpack.optimize.ModuleConcatenationPlugin()); +} + +module.exports = { + entry, + module: { + rules: [{ + test: /\.vue$/, + exclude: /node_modules/, + use: [{ + loader: 'vue-loader', + options: { + cssSourceMap: false, + compilerOptions: { + preserveWhitespace: false } - }, { - loader: 'replace', - query: { - search: /%base64:(.+?)%/g.toString(), - replace: 'base64replacement' - } - }, { - loader: 'replace', - query: { - search: i18nReplacer.pattern.toString(), - replace: 'i18nReplacement', - i18n: true, - lang - } - }, { - loader: 'replace', - query: { - search: faPattern.toString(), - replace: 'faReplacement' - } - }, { - loader: 'replace', - query: { - search: /^<template>([\s\S]+?)\r?\n<\/template>/.toString(), - replace: 'collapseSpacesReplacement' - } - }] + } }, { - test: /\.styl(us)?$/, - exclude: /node_modules/, - oneOf: [{ - resourceQuery: /module/, - use: [{ - loader: 'vue-style-loader' - }, { - loader: 'css-loader', - options: { - modules: true, - minimize: true - } - }, { - loader: 'stylus-loader' - }] - }, { - use: [{ - loader: 'vue-style-loader' - }, { - loader: 'css-loader', - options: { - minimize: true - } - }, { - loader: 'stylus-loader' - }] - }] + loader: 'replace', + query: { + search: /%base64:(.+?)%/g.toString(), + replace: 'base64replacement' + } }, { - test: /\.scss$/, - exclude: /node_modules/, + loader: 'replace', + query: { + search: i18nPattern.toString(), + replace: 'i18nReplacement', + i18n: true + } + }, { + loader: 'replace', + query: { + search: faPattern.toString(), + replace: 'faReplacement' + } + }, { + loader: 'replace', + query: { + search: /^<template>([\s\S]+?)\r?\n<\/template>/.toString(), + replace: 'collapseSpacesReplacement' + } + }] + }, { + test: /\.styl(us)?$/, + exclude: /node_modules/, + oneOf: [{ + resourceQuery: /module/, use: [{ - loader: 'style-loader' + loader: 'vue-style-loader' }, { loader: 'css-loader', options: { + modules: true, minimize: true } }, { - loader: 'sass-loader', - options: { - importer: jsonImporter, - } + loader: 'stylus-loader' }] }, { - test: /\.css$/, use: [{ loader: 'vue-style-loader' }, { @@ -221,52 +195,79 @@ module.exports = entries.map(x => { options: { minimize: true } - }] - }, { - test: /\.(eot|woff|woff2|svg|ttf)([\?]?.*)$/, - loader: 'url-loader' - }, { - test: /\.ts$/, - exclude: /node_modules/, - use: [{ - loader: 'ts-loader', - options: { - happyPackMode: true, - configFile: __dirname + '/src/client/app/tsconfig.json', - appendTsSuffixTo: [/\.vue$/] - } }, { - loader: 'replace', - query: { - search: i18nReplacer.pattern.toString(), - replace: 'i18nReplacement', - i18n: true, - lang - } - }, { - loader: 'replace', - query: { - search: faPattern.toString(), - replace: 'faReplacement' - } + loader: 'stylus-loader' }] }] - }, - plugins, - output, - resolve: { - extensions: [ - '.js', '.ts', '.json' - ], - alias: { - 'const.styl': __dirname + '/src/client/const.styl' - } - }, - resolveLoader: { - modules: ['node_modules', './webpack/loaders'] - }, - cache: true, - devtool: false, //'source-map', - mode: isProduction ? 'production' : 'development' - }; -}); + }, { + test: /\.scss$/, + exclude: /node_modules/, + use: [{ + loader: 'style-loader' + }, { + loader: 'css-loader', + options: { + minimize: true + } + }, { + loader: 'sass-loader', + options: { + importer: jsonImporter, + } + }] + }, { + test: /\.css$/, + use: [{ + loader: 'vue-style-loader' + }, { + loader: 'css-loader', + options: { + minimize: true + } + }] + }, { + test: /\.(eot|woff|woff2|svg|ttf)([\?]?.*)$/, + loader: 'url-loader' + }, { + test: /\.ts$/, + exclude: /node_modules/, + use: [{ + loader: 'ts-loader', + options: { + happyPackMode: true, + configFile: __dirname + '/src/client/app/tsconfig.json', + appendTsSuffixTo: [/\.vue$/] + } + }, { + loader: 'replace', + query: { + search: i18nPattern.toString(), + replace: 'i18nReplacement', + i18n: true + } + }, { + loader: 'replace', + query: { + search: faPattern.toString(), + replace: 'faReplacement' + } + }] + }] + }, + plugins, + output, + resolve: { + extensions: [ + '.js', '.ts', '.json' + ], + alias: { + 'const.styl': __dirname + '/src/client/const.styl' + } + }, + resolveLoader: { + modules: ['node_modules', './webpack/loaders'] + }, + cache: true, + devtool: false, //'source-map', + mode: isProduction ? 'production' : 'development' +}; diff --git a/webpack/i18n.ts b/webpack/i18n.ts new file mode 100644 index 0000000000..de4d02e9d9 --- /dev/null +++ b/webpack/i18n.ts @@ -0,0 +1,24 @@ +/** + * Replace i18n texts + */ + +export const pattern = /%i18n:([a-z0-9_\-@\.\!]+?)%/g; + +export const replacement = (ctx, match, key) => { + const client = '/src/client/app/'; + let name = null; + + const shouldEscape = key[0] == '!'; + if (shouldEscape) { + key = key.substr(1); + } + + if (key[0] == '@') { + name = ctx.src.substr(ctx.src.indexOf(client) + client.length); + key = key.substr(1); + } + + const path = name ? `${name}|${key}` : key; + + return shouldEscape ? `%i18n:!${path}%` : `%i18n:${path}%`; +}; From 6fb112d000c7b1173452294cc0cc822a359cf2b0 Mon Sep 17 00:00:00 2001 From: syuilo <Syuilotan@yahoo.co.jp> Date: Thu, 17 May 2018 12:44:55 +0900 Subject: [PATCH 13/14] Remove needless plugin --- webpack.config.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/webpack.config.ts b/webpack.config.ts index 3ac3c4e297..b2f67c914f 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -11,7 +11,6 @@ const minifyHtml = require('html-minifier').minify; const WebpackOnBuildPlugin = require('on-build-webpack'); //const HardSourceWebpackPlugin = require('hard-source-webpack-plugin'); const ProgressBarPlugin = require('progress-bar-webpack-plugin'); -const I18nPlugin = require('webpack-multilang-i18n-plugin'); import I18nReplacer from './src/build/i18n'; import { pattern as i18nPattern, replacement as i18nReplacement } from './webpack/i18n'; @@ -123,8 +122,7 @@ const plugins = [ }); //#endregion }), - new VueLoaderPlugin(), - new I18nPlugin() + new VueLoaderPlugin() ]; if (isProduction) { From e08b2a9481fd050e0437f762c358baecf909b788 Mon Sep 17 00:00:00 2001 From: syuilo <syuilotan@yahoo.co.jp> Date: Thu, 17 May 2018 15:25:41 +0900 Subject: [PATCH 14/14] oops --- src/build/i18n.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build/i18n.ts b/src/build/i18n.ts index 212a5837dd..addc35ce59 100644 --- a/src/build/i18n.ts +++ b/src/build/i18n.ts @@ -7,7 +7,7 @@ import locale from '../../locales'; export default class Replacer { private lang: string; - public pattern = /%i18n:([a-z0-9_\-\.\!]+?)%/g; + public pattern = /%i18n:([a-z0-9_\-\.\/\|\!]+?)%/g; constructor(lang: string) { this.lang = lang;