Separate translations and source code. Improve detection of preferred language.
This commit is contained in:
parent
d009009cdf
commit
644712bca7
@ -37,12 +37,12 @@
|
|||||||
"angular-socialshare": "^2.3.8",
|
"angular-socialshare": "^2.3.8",
|
||||||
"angular-storage": "0.0.15",
|
"angular-storage": "0.0.15",
|
||||||
"angular-touch": "1.5.8",
|
"angular-touch": "1.5.8",
|
||||||
"angular-translate": "2.13.1",
|
"angular-translate": "2.18.1",
|
||||||
"angular-translate-handler-log": "2.13.1",
|
"angular-translate-handler-log": "2.18.1",
|
||||||
"angular-translate-interpolation-messageformat": "2.13.1",
|
"angular-translate-interpolation-messageformat": "2.18.1",
|
||||||
"angular-translate-loader-static-files": "2.13.1",
|
"angular-translate-loader-static-files": "2.18.1",
|
||||||
"angular-translate-storage-cookie": "2.13.1",
|
"angular-translate-storage-cookie": "2.18.1",
|
||||||
"angular-translate-storage-local": "2.13.1",
|
"angular-translate-storage-local": "2.18.1",
|
||||||
"angular-ui-ace": "^0.2.3",
|
"angular-ui-ace": "^0.2.3",
|
||||||
"angular-ui-router": "^0.3.1",
|
"angular-ui-router": "^0.3.1",
|
||||||
"angular-websocket": "^2.0.1",
|
"angular-websocket": "^2.0.1",
|
||||||
|
|||||||
@ -15,10 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
import injectTapEventPlugin from 'react-tap-event-plugin';
|
import injectTapEventPlugin from 'react-tap-event-plugin';
|
||||||
import UrlHandler from './url.handler';
|
import UrlHandler from './url.handler';
|
||||||
import addLocaleKorean from './locale/locale.constant-ko';
|
|
||||||
import addLocaleChinese from './locale/locale.constant-zh';
|
|
||||||
import addLocaleRussian from './locale/locale.constant-ru';
|
|
||||||
import addLocaleSpanish from './locale/locale.constant-es';
|
|
||||||
|
|
||||||
/* eslint-disable import/no-unresolved, import/default */
|
/* eslint-disable import/no-unresolved, import/default */
|
||||||
|
|
||||||
@ -38,46 +34,32 @@ export default function AppConfig($provide,
|
|||||||
$mdThemingProvider,
|
$mdThemingProvider,
|
||||||
$httpProvider,
|
$httpProvider,
|
||||||
$translateProvider,
|
$translateProvider,
|
||||||
storeProvider,
|
storeProvider) {
|
||||||
locales) {
|
|
||||||
|
|
||||||
injectTapEventPlugin();
|
injectTapEventPlugin();
|
||||||
$locationProvider.html5Mode(true);
|
$locationProvider.html5Mode(true);
|
||||||
$urlRouterProvider.otherwise(UrlHandler);
|
$urlRouterProvider.otherwise(UrlHandler);
|
||||||
storeProvider.setCaching(false);
|
storeProvider.setCaching(false);
|
||||||
|
|
||||||
$translateProvider.useSanitizeValueStrategy(null);
|
$translateProvider.useSanitizeValueStrategy(null)
|
||||||
$translateProvider.useMissingTranslationHandler('tbMissingTranslationHandler');
|
.useMissingTranslationHandler('tbMissingTranslationHandler')
|
||||||
$translateProvider.addInterpolation('$translateMessageFormatInterpolation');
|
/* .useMissingTranslationHandlerLog() */
|
||||||
$translateProvider.fallbackLanguage('en_US');
|
.addInterpolation('$translateMessageFormatInterpolation')
|
||||||
|
.useStaticFilesLoader({
|
||||||
addLocaleKorean(locales);
|
prefix: PUBLIC_PATH + 'locale/locale.constant-', //eslint-disable-line
|
||||||
addLocaleChinese(locales);
|
suffix: '.json'
|
||||||
addLocaleRussian(locales);
|
})
|
||||||
addLocaleSpanish(locales);
|
.registerAvailableLanguageKeys(['en', 'es', 'it', 'ko', 'ru', 'zh'], {
|
||||||
|
'en_*': 'en',
|
||||||
for (var langKey in locales) {
|
'es_*': 'es',
|
||||||
var translationTable = locales[langKey];
|
'it_*': 'it',
|
||||||
$translateProvider.translations(langKey, translationTable);
|
'ko_*': 'ko',
|
||||||
}
|
'ru_*': 'ru',
|
||||||
|
'zh_*': 'zh'
|
||||||
var lang = $translateProvider.resolveClientLocale();
|
})
|
||||||
if (lang) {
|
.fallbackLanguage('en') // must be before determinePreferredLanguage
|
||||||
lang = lang.toLowerCase();
|
.uniformLanguageTag('java') // must be before determinePreferredLanguage
|
||||||
if (lang.startsWith('ko')) {
|
.determinePreferredLanguage();
|
||||||
$translateProvider.preferredLanguage('ko_KR');
|
|
||||||
} else if (lang.startsWith('zh')) {
|
|
||||||
$translateProvider.preferredLanguage('zh_CN');
|
|
||||||
} else if (lang.startsWith('es')) {
|
|
||||||
$translateProvider.preferredLanguage('es_ES');
|
|
||||||
} else if (lang.startsWith('ru')) {
|
|
||||||
$translateProvider.preferredLanguage('ru_RU');
|
|
||||||
} else {
|
|
||||||
$translateProvider.preferredLanguage('en_US');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$translateProvider.preferredLanguage('en_US');
|
|
||||||
}
|
|
||||||
|
|
||||||
$httpProvider.interceptors.push('globalInterceptor');
|
$httpProvider.interceptors.push('globalInterceptor');
|
||||||
|
|
||||||
|
|||||||
@ -51,7 +51,7 @@ import react from 'ngreact';
|
|||||||
import '@flowjs/ng-flow/dist/ng-flow-standalone.min';
|
import '@flowjs/ng-flow/dist/ng-flow-standalone.min';
|
||||||
import 'ngFlowchart/dist/ngFlowchart';
|
import 'ngFlowchart/dist/ngFlowchart';
|
||||||
|
|
||||||
import thingsboardLocales from './locale/locale.constant';
|
import thingsboardTranslateHandler from './locale/translate-handler';
|
||||||
import thingsboardLogin from './login';
|
import thingsboardLogin from './login';
|
||||||
import thingsboardDialogs from './components/datakey-config-dialog.controller';
|
import thingsboardDialogs from './components/datakey-config-dialog.controller';
|
||||||
import thingsboardMenu from './services/menu.service';
|
import thingsboardMenu from './services/menu.service';
|
||||||
@ -117,7 +117,7 @@ angular.module('thingsboard', [
|
|||||||
react.name,
|
react.name,
|
||||||
'flow',
|
'flow',
|
||||||
'flowchart',
|
'flowchart',
|
||||||
thingsboardLocales,
|
thingsboardTranslateHandler,
|
||||||
thingsboardLogin,
|
thingsboardLogin,
|
||||||
thingsboardDialogs,
|
thingsboardDialogs,
|
||||||
thingsboardMenu,
|
thingsboardMenu,
|
||||||
|
|||||||
1456
ui/src/app/locale/locale.constant-en.json
Normal file
1456
ui/src/app/locale/locale.constant-en.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1315
ui/src/app/locale/locale.constant-es.json
Normal file
1315
ui/src/app/locale/locale.constant-es.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1443
ui/src/app/locale/locale.constant-it.json
Normal file
1443
ui/src/app/locale/locale.constant-it.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1337
ui/src/app/locale/locale.constant-ko.json
Normal file
1337
ui/src/app/locale/locale.constant-ko.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1363
ui/src/app/locale/locale.constant-ru.json
Normal file
1363
ui/src/app/locale/locale.constant-ru.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1446
ui/src/app/locale/locale.constant-zh.json
Normal file
1446
ui/src/app/locale/locale.constant-zh.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -13,8 +13,12 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
export default angular.module('thingsboard.locale', [])
|
||||||
|
.factory('tbMissingTranslationHandler', ThingsboardMissingTranslateHandler)
|
||||||
|
.name;
|
||||||
|
|
||||||
/*@ngInject*/
|
/*@ngInject*/
|
||||||
export default function ThingsboardMissingTranslateHandler($log, types) {
|
function ThingsboardMissingTranslateHandler($log, types) {
|
||||||
|
|
||||||
return function (translationId) {
|
return function (translationId) {
|
||||||
if (translationId && !translationId.startsWith(types.translate.customTranslationsPrefix)) {
|
if (translationId && !translationId.startsWith(types.translate.customTranslationsPrefix)) {
|
||||||
|
|||||||
@ -21,6 +21,8 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
|
const PUBLIC_RESOURCE_PATH = '/';
|
||||||
|
|
||||||
/* devtool: 'cheap-module-eval-source-map', */
|
/* devtool: 'cheap-module-eval-source-map', */
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@ -32,7 +34,7 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, 'target/generated-resources/public/static'),
|
path: path.resolve(__dirname, 'target/generated-resources/public/static'),
|
||||||
publicPath: '/',
|
publicPath: PUBLIC_RESOURCE_PATH,
|
||||||
filename: 'bundle.js',
|
filename: 'bundle.js',
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
@ -45,7 +47,8 @@ module.exports = {
|
|||||||
moment: "moment"
|
moment: "moment"
|
||||||
}),
|
}),
|
||||||
new CopyWebpackPlugin([
|
new CopyWebpackPlugin([
|
||||||
{ from: './src/thingsboard.ico', to: 'thingsboard.ico' }
|
{ from: './src/thingsboard.ico', to: 'thingsboard.ico' },
|
||||||
|
{ from: './src/app/locale', to: 'locale' }
|
||||||
]),
|
]),
|
||||||
new webpack.HotModuleReplacementPlugin(),
|
new webpack.HotModuleReplacementPlugin(),
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
@ -65,6 +68,7 @@ module.exports = {
|
|||||||
'process.env': {
|
'process.env': {
|
||||||
NODE_ENV: JSON.stringify('development'),
|
NODE_ENV: JSON.stringify('development'),
|
||||||
},
|
},
|
||||||
|
PUBLIC_PATH: PUBLIC_RESOURCE_PATH
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
node: {
|
node: {
|
||||||
@ -118,6 +122,10 @@ module.exports = {
|
|||||||
'img?minimize'
|
'img?minimize'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
test: /\.json$/,
|
||||||
|
loader: 'json-loader'
|
||||||
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'html-minifier-loader': {
|
'html-minifier-loader': {
|
||||||
|
|||||||
@ -21,6 +21,8 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
|
const PUBLIC_RESOURCE_PATH = '/static/';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
entry: [
|
entry: [
|
||||||
@ -29,7 +31,7 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, 'target/generated-resources/public/static'),
|
path: path.resolve(__dirname, 'target/generated-resources/public/static'),
|
||||||
publicPath: '/static/',
|
publicPath: PUBLIC_RESOURCE_PATH,
|
||||||
filename: 'bundle.[hash].js',
|
filename: 'bundle.[hash].js',
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
@ -42,7 +44,8 @@ module.exports = {
|
|||||||
moment: "moment"
|
moment: "moment"
|
||||||
}),
|
}),
|
||||||
new CopyWebpackPlugin([
|
new CopyWebpackPlugin([
|
||||||
{from: './src/thingsboard.ico', to: 'thingsboard.ico'}
|
{ from: './src/thingsboard.ico', to: 'thingsboard.ico'},
|
||||||
|
{ from: './src/app/locale', to: 'locale' }
|
||||||
]),
|
]),
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
template: './src/index.html',
|
template: './src/index.html',
|
||||||
@ -63,6 +66,7 @@ module.exports = {
|
|||||||
'process.env': {
|
'process.env': {
|
||||||
NODE_ENV: JSON.stringify('production'),
|
NODE_ENV: JSON.stringify('production'),
|
||||||
},
|
},
|
||||||
|
PUBLIC_PATH: PUBLIC_RESOURCE_PATH
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
node: {
|
node: {
|
||||||
@ -116,6 +120,10 @@ module.exports = {
|
|||||||
'img?minimize'
|
'img?minimize'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
test: /\.json$/,
|
||||||
|
loader: 'json-loader'
|
||||||
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'html-minifier-loader': {
|
'html-minifier-loader': {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user