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