From 97f0b29d4a716bf1bba7d12c250062da9b2e7c03 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 3 Nov 2017 17:46:42 +0900 Subject: [PATCH] [Client] set lang --- src/web/app/init.js | 5 +++++ webpack/plugins/const.ts | 3 ++- webpack/plugins/index.ts | 4 ++-- webpack/webpack.config.ts | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/web/app/init.js b/src/web/app/init.js index cb661c259..5a6899ed4 100644 --- a/src/web/app/init.js +++ b/src/web/app/init.js @@ -21,6 +21,11 @@ require('./common/tags'); console.info(`Misskey v${VERSION} (葵 aoi)`); +{ // Set lang attr + const html = document.documentElement; + html.setAttribute('lang', LANG); +} + { // Set description meta tag const head = document.getElementsByTagName('head')[0]; const meta = document.createElement('meta'); diff --git a/webpack/plugins/const.ts b/webpack/plugins/const.ts index ccfcb4526..f64160b01 100644 --- a/webpack/plugins/const.ts +++ b/webpack/plugins/const.ts @@ -7,7 +7,8 @@ import * as webpack from 'webpack'; import version from '../../src/version'; const constants = require('../../src/const.json'); -export default () => new webpack.DefinePlugin({ +export default lang => new webpack.DefinePlugin({ VERSION: JSON.stringify(version), + LANG: JSON.stringify(lang), THEME_COLOR: JSON.stringify(constants.themeColor) }); diff --git a/webpack/plugins/index.ts b/webpack/plugins/index.ts index d5191f155..345af7df9 100644 --- a/webpack/plugins/index.ts +++ b/webpack/plugins/index.ts @@ -8,9 +8,9 @@ import banner from './banner'; const env = process.env.NODE_ENV; const isProduction = env === 'production'; -export default version => { +export default (version, lang) => { const plugins = [ - constant(), + constant(lang), new StringReplacePlugin(), hoist() ]; diff --git a/webpack/webpack.config.ts b/webpack/webpack.config.ts index 066df1815..97782a410 100644 --- a/webpack/webpack.config.ts +++ b/webpack/webpack.config.ts @@ -32,7 +32,7 @@ module.exports = langs.map(([lang, locale]) => { name, entry, module: module_(lang, locale), - plugins: plugins(version), + plugins: plugins(version, lang), output }; });