Browse Source

Separate translations and source code. Improve detection of preferred language.

pull/941/head
DK 8 years ago
parent
commit
644712bca7
  1. 12
      ui/package.json
  2. 60
      ui/src/app/app.config.js
  3. 4
      ui/src/app/app.js
  4. 1456
      ui/src/app/locale/locale.constant-en.json
  5. 1333
      ui/src/app/locale/locale.constant-es.js
  6. 1315
      ui/src/app/locale/locale.constant-es.json
  7. 1463
      ui/src/app/locale/locale.constant-it.js
  8. 1443
      ui/src/app/locale/locale.constant-it.json
  9. 1354
      ui/src/app/locale/locale.constant-ko.js
  10. 1337
      ui/src/app/locale/locale.constant-ko.json
  11. 1381
      ui/src/app/locale/locale.constant-ru.js
  12. 1363
      ui/src/app/locale/locale.constant-ru.json
  13. 1465
      ui/src/app/locale/locale.constant-zh.js
  14. 1446
      ui/src/app/locale/locale.constant-zh.json
  15. 1478
      ui/src/app/locale/locale.constant.js
  16. 6
      ui/src/app/locale/translate-handler.js
  17. 12
      ui/webpack.config.dev.js
  18. 12
      ui/webpack.config.prod.js

12
ui/package.json

@ -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",

60
ui/src/app/app.config.js

@ -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');

4
ui/src/app/app.js

@ -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

File diff suppressed because it is too large

1333
ui/src/app/locale/locale.constant-es.js

File diff suppressed because it is too large

1315
ui/src/app/locale/locale.constant-es.json

File diff suppressed because it is too large

1463
ui/src/app/locale/locale.constant-it.js

File diff suppressed because it is too large

1443
ui/src/app/locale/locale.constant-it.json

File diff suppressed because it is too large

1354
ui/src/app/locale/locale.constant-ko.js

File diff suppressed because it is too large

1337
ui/src/app/locale/locale.constant-ko.json

File diff suppressed because it is too large

1381
ui/src/app/locale/locale.constant-ru.js

File diff suppressed because it is too large

1363
ui/src/app/locale/locale.constant-ru.json

File diff suppressed because it is too large

1465
ui/src/app/locale/locale.constant-zh.js

File diff suppressed because it is too large

1446
ui/src/app/locale/locale.constant-zh.json

File diff suppressed because it is too large

1478
ui/src/app/locale/locale.constant.js

File diff suppressed because it is too large

6
ui/src/app/locale/translate-handler.js

@ -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)) {

12
ui/webpack.config.dev.js

@ -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': {

12
ui/webpack.config.prod.js

@ -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…
Cancel
Save