diff --git a/app.js b/app.js index 0e456ebc..08289faf 100644 --- a/app.js +++ b/app.js @@ -2,9 +2,51 @@ var Hedera = require ('hedera/hedera'); Vn.includeCss ('pages/main/style.css'); -window.onload = function main () +window.onload = function () { + Vn.Locale.init (); + var lang = Vn.Locale.language; + loadLocale (lang, main); +} + +function main (req) +{ + var keys = req.keys (); + + for (var i = 0; i < keys.length; i++) + Vn.Locale.add (req (keys[i])); + hederaWeb = new Hedera.App (); hederaWeb.run (); } +function loadLocale (lang, cb) +{ + switch (lang) + { + case 'ca': + require.ensure ([], function (){ + cb (require.context ('locale/ca/js')); }); + break; + case 'es': + require.ensure ([], function () { + cb (require.context ('locale/es/js')); }); + break; + case 'fr': + require.ensure ([], function () { + cb (require.context ('locale/fr/js')); }); + break; + case 'mn': + require.ensure ([], function () { + cb (require.context ('locale/mn/js')); }); + break; + case 'pt': + require.ensure ([], function () { + cb (require.context ('locale/pt/js')); }); + break; + default: + require.ensure ([], function () { + cb (require.context ('locale/en/js')); }); + } +} + diff --git a/forms/ecomerce/catalog/catalog.js b/forms/ecomerce/catalog/catalog.js index 2fb2895a..b8a720c2 100644 --- a/forms/ecomerce/catalog/catalog.js +++ b/forms/ecomerce/catalog/catalog.js @@ -61,7 +61,7 @@ Hedera.Catalog = new Class else { this.$('view-button').setProperties ({ - image: 'view-grid', + icon: 'view-grid', tip: _('Grid view') }); this.view = Hedera.Catalog.View.LIST; diff --git a/js/db/db.js b/js/db/db.js index 3d824f43..e1ba4ec9 100644 --- a/js/db/db.js +++ b/js/db/db.js @@ -1,8 +1,6 @@ require ('sql/sql'); -Vn.Locale.loadScript ('js/db.js'); - Db = module.exports = { Connection : require ('./connection') ,Result : require ('./result') diff --git a/js/hedera/hedera.js b/js/hedera/hedera.js index 61a48cab..2bac9b3d 100644 --- a/js/hedera/hedera.js +++ b/js/hedera/hedera.js @@ -2,7 +2,6 @@ require ('htk/htk'); Vn.includeCss ('js/hedera/style.css'); -Vn.Locale.loadScript ('js/hedera.js'); Hedera = module.exports = { Login : require ('./login') diff --git a/js/htk/htk.js b/js/htk/htk.js index e66c29dc..4520f71b 100644 --- a/js/htk/htk.js +++ b/js/htk/htk.js @@ -2,8 +2,6 @@ require ('db/db'); require ('./style.css'); -Vn.Locale.loadScript ('js/htk.js'); - Htk = module.exports = { Widget : require ('./widget') ,Popup : require ('./popup') diff --git a/js/vn/locale.js b/js/vn/locale.js index cb2874d5..907e1ea8 100644 --- a/js/vn/locale.js +++ b/js/vn/locale.js @@ -58,10 +58,10 @@ module.exports = callback (success); } - ,add: function (strings) + ,add: function (translations) { - for (var stringId in strings) - vnLocaleStrings[stringId] = strings[stringId]; + for (var str in translations) + vnLocaleStrings[str] = translations[str]; } } diff --git a/js/vn/vn.js b/js/vn/vn.js index b0e6cabd..89320e75 100644 --- a/js/vn/vn.js +++ b/js/vn/vn.js @@ -415,5 +415,3 @@ Vn = module.exports = { } }; -Vn.Locale.loadScript ('js/vn.js'); - diff --git a/locale/ca/js/db.js b/locale/ca/js/db.json similarity index 92% rename from locale/ca/js/db.js rename to locale/ca/js/db.json index d85d620f..64e50adf 100644 --- a/locale/ca/js/db.js +++ b/locale/ca/js/db.json @@ -1,8 +1,7 @@ -Vn.Locale.add -({ +{ "ConnError": "Error en la conexió" ,"BadServerReply": "Resposta del servidor incorrecta" ,"ModelNotUpdatable": "Aquest model no és actualitzable" ,"RowNotExists": "El registre no existeix o ha sigut esborrat" ,"ColNotExists": "La columna no existeix" -}); +} diff --git a/locale/ca/js/hedera.js b/locale/ca/js/hedera.json similarity index 98% rename from locale/ca/js/hedera.js rename to locale/ca/js/hedera.json index c7a7bcaf..63e317c7 100644 --- a/locale/ca/js/hedera.js +++ b/locale/ca/js/hedera.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "User": "Usuari" ,"Password": "Contrasenya" ,"Beta": "Beta" @@ -56,4 +55,4 @@ Vn.Locale.add ,"Configuration": "Configuració" ,"Account": "Compte" ,"Addresses": "Direccions" -}); +} diff --git a/locale/ca/js/htk.js b/locale/ca/js/htk.json similarity index 97% rename from locale/ca/js/htk.js rename to locale/ca/js/htk.json index 5103c94b..48d74aee 100644 --- a/locale/ca/js/htk.js +++ b/locale/ca/js/htk.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "True": "Sí" ,"False": "No" ,"Null": "Nul" @@ -28,4 +27,4 @@ Vn.Locale.add ,"Next": "Següent" ,"Search": "Cercar" ,"Search...": "Cercar..." -}); +} diff --git a/locale/ca/js/vn.js b/locale/ca/js/vn.json similarity index 97% rename from locale/ca/js/vn.js rename to locale/ca/js/vn.json index 63e37521..147f984d 100644 --- a/locale/ca/js/vn.js +++ b/locale/ca/js/vn.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "Sunday": "Diumenge" ,"Monday": "Dilluns" ,"Tuesday": "Dimarts" @@ -43,4 +42,4 @@ Vn.Locale.add ,"Dec": "Des" ,"%A, %B %e": "%A, %e de %B" -}); +} diff --git a/locale/en/js/db.js b/locale/en/js/db.json similarity index 91% rename from locale/en/js/db.js rename to locale/en/js/db.json index 591d711f..0ea58851 100644 --- a/locale/en/js/db.js +++ b/locale/en/js/db.json @@ -1,8 +1,7 @@ -Vn.Locale.add -({ +{ "ConnError": "Connection failed" ,"BadServerReply": "Bad server reply" ,"ModelNotUpdatable": "Model not updatable" ,"RowNotExists": "The record does not exist or has been deleted" ,"ColNotExists": "The column does not exist" -}); +} diff --git a/locale/en/js/hedera.js b/locale/en/js/hedera.json similarity index 98% rename from locale/en/js/hedera.js rename to locale/en/js/hedera.json index 65df8ac5..e65647ed 100644 --- a/locale/en/js/hedera.js +++ b/locale/en/js/hedera.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "User": "User" ,"Password": "Password" ,"Beta": "Beta" @@ -56,4 +55,4 @@ Vn.Locale.add ,"Configuration": "Configuration" ,"Account": "Account" ,"Addresses": "Addresses" -}); +} diff --git a/locale/en/js/htk.js b/locale/en/js/htk.json similarity index 97% rename from locale/en/js/htk.js rename to locale/en/js/htk.json index d468f283..7f34c222 100644 --- a/locale/en/js/htk.js +++ b/locale/en/js/htk.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "True": "True" ,"False": "False" ,"Null": "Null" @@ -28,4 +27,4 @@ Vn.Locale.add ,"Next": "Next" ,"Search": "Search" ,"Search...": "Search..." -}); +} diff --git a/locale/en/js/vn.js b/locale/en/js/vn.json similarity index 97% rename from locale/en/js/vn.js rename to locale/en/js/vn.json index 673b252a..6ab3efb8 100644 --- a/locale/en/js/vn.js +++ b/locale/en/js/vn.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "Sunday": "Sunday" ,"Monday": "Monday" ,"Tuesday": "Tuesday" @@ -43,4 +42,4 @@ Vn.Locale.add ,"Dec": "Dic" ,"%A, %B %e": "%A, %B %e" -}); +} diff --git a/locale/es/js/db.js b/locale/es/js/db.json similarity index 92% rename from locale/es/js/db.js rename to locale/es/js/db.json index 52788c6d..91143f97 100644 --- a/locale/es/js/db.js +++ b/locale/es/js/db.json @@ -1,8 +1,7 @@ -Vn.Locale.add -({ +{ "ConnError": "Error en la conexión" ,"BadServerReply": "Respuesta del servidor incorrecta" ,"ModelNotUpdatable": "Este modelo no es actualizable" ,"RowNotExists": "El registro no existe o a sido borrado" ,"ColNotExists": "La columna no existe" -}); +} diff --git a/locale/es/js/hedera.js b/locale/es/js/hedera.json similarity index 98% rename from locale/es/js/hedera.js rename to locale/es/js/hedera.json index af7aa771..d94307bb 100644 --- a/locale/es/js/hedera.js +++ b/locale/es/js/hedera.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "User": "Usuario" ,"Password": "Contraseña" ,"Beta": "Beta" @@ -56,4 +55,4 @@ Vn.Locale.add ,"Configuration": "Configuración" ,"Account": "Cuenta" ,"Addresses": "Direcciones" -}); +} diff --git a/locale/es/js/htk.js b/locale/es/js/htk.json similarity index 97% rename from locale/es/js/htk.js rename to locale/es/js/htk.json index 83d56af6..c2f600a6 100644 --- a/locale/es/js/htk.js +++ b/locale/es/js/htk.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "True": "Si" ,"False": "No" ,"Null": "Nulo" @@ -28,4 +27,4 @@ Vn.Locale.add ,"Next": "Siguiente" ,"Search": "Buscar" ,"Search...": "Buscar..." -}); +} diff --git a/locale/es/js/vn.js b/locale/es/js/vn.json similarity index 97% rename from locale/es/js/vn.js rename to locale/es/js/vn.json index b1b86f0a..697d3d52 100644 --- a/locale/es/js/vn.js +++ b/locale/es/js/vn.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "Sunday": "Domingo" ,"Monday": "Lunes" ,"Tuesday": "Martes" @@ -43,4 +42,4 @@ Vn.Locale.add ,"Dec": "Dic" ,"%A, %B %e": "%A, %e de %B" -}); +} diff --git a/locale/fr/js/db.js b/locale/fr/js/db.json similarity index 92% rename from locale/fr/js/db.js rename to locale/fr/js/db.json index 3bee647e..5a72cce1 100644 --- a/locale/fr/js/db.js +++ b/locale/fr/js/db.json @@ -1,8 +1,7 @@ -Vn.Locale.add -({ +{ "ConnError": "Échec de la connexion" ,"BadServerReply": "Réponse du serveur incorrecte" ,"ModelNotUpdatable": "Ce modèle n'est pas modifiable" ,"RowNotExists": "Le dossier n'existe pas ou a été supprimée" ,"ColNotExists": "N'existe pas la colonne" -}); +} diff --git a/locale/fr/js/hedera.js b/locale/fr/js/hedera.json similarity index 98% rename from locale/fr/js/hedera.js rename to locale/fr/js/hedera.json index cb913dd4..f85013c7 100644 --- a/locale/fr/js/hedera.js +++ b/locale/fr/js/hedera.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "User": "Utilisateur" ,"Password": "Mot de passe" ,"Beta": "Beta" @@ -56,4 +55,4 @@ Vn.Locale.add ,"Configuration": "Configuration" ,"Account": "Compte" ,"Addresses": "Adresses" -}); +} diff --git a/locale/fr/js/htk.js b/locale/fr/js/htk.json similarity index 97% rename from locale/fr/js/htk.js rename to locale/fr/js/htk.json index 9b871c88..56e03bce 100644 --- a/locale/fr/js/htk.js +++ b/locale/fr/js/htk.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "True": "Si" ,"False": "Aucun" ,"Null": "Nul" @@ -28,4 +27,4 @@ Vn.Locale.add ,"Next": "Suivant" ,"Search": "Recherche" ,"Search...": "Recherche..." -}); +} diff --git a/locale/fr/js/vn.js b/locale/fr/js/vn.json similarity index 97% rename from locale/fr/js/vn.js rename to locale/fr/js/vn.json index 4ad0530c..7fec0639 100644 --- a/locale/fr/js/vn.js +++ b/locale/fr/js/vn.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "Sunday": "Dimanche" ,"Monday": "Lundi" ,"Tuesday": "Mardi" @@ -43,4 +42,4 @@ Vn.Locale.add ,"Dec": "Déc" ,"%A, %B %e": "%A, %B %e" -}); +} diff --git a/locale/mn/js/db.js b/locale/mn/js/db.json similarity index 91% rename from locale/mn/js/db.js rename to locale/mn/js/db.json index 591d711f..0ea58851 100644 --- a/locale/mn/js/db.js +++ b/locale/mn/js/db.json @@ -1,8 +1,7 @@ -Vn.Locale.add -({ +{ "ConnError": "Connection failed" ,"BadServerReply": "Bad server reply" ,"ModelNotUpdatable": "Model not updatable" ,"RowNotExists": "The record does not exist or has been deleted" ,"ColNotExists": "The column does not exist" -}); +} diff --git a/locale/mn/js/hedera.js b/locale/mn/js/hedera.json similarity index 99% rename from locale/mn/js/hedera.js rename to locale/mn/js/hedera.json index cda44b2c..91e71dba 100644 --- a/locale/mn/js/hedera.js +++ b/locale/mn/js/hedera.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "User": "Хэрэглэгчийн" ,"Password": "нууц үг" ,"Beta": "Бета" @@ -56,4 +55,4 @@ Vn.Locale.add ,"Configuration": "Тохиргоо" ,"Account": "Дансны" ,"Addresses": "хаягууд" -}); +} diff --git a/locale/mn/js/htk.js b/locale/mn/js/htk.json similarity index 97% rename from locale/mn/js/htk.js rename to locale/mn/js/htk.json index a3a262fd..b9b6f6c3 100644 --- a/locale/mn/js/htk.js +++ b/locale/mn/js/htk.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "True": "True" ,"False": "False" ,"Null": "Null" @@ -28,4 +27,4 @@ Vn.Locale.add ,"Next": "Next" ,"Search": "хайх" ,"Search...": "хайх..." -}); +} diff --git a/locale/mn/js/vn.js b/locale/mn/js/vn.json similarity index 97% rename from locale/mn/js/vn.js rename to locale/mn/js/vn.json index 7c6e8dfa..1de82659 100644 --- a/locale/mn/js/vn.js +++ b/locale/mn/js/vn.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "Sunday": "Ням гараг" ,"Monday": "Даваа гариг" ,"Tuesday": "Мягмар" @@ -43,4 +42,4 @@ Vn.Locale.add ,"Dec": "Арв" ,"%A, %B %e": "%A, %B %e" -}); +} diff --git a/locale/pt/forms/account/address-list.json b/locale/pt/forms/account/address-list.json index a9afe09e..8373a9cf 100644 --- a/locale/pt/forms/account/address-list.json +++ b/locale/pt/forms/account/address-list.json @@ -1,5 +1,5 @@ { - "Addresses": "Endereços + "Addresses": "Endereços" ,"Return": "Voltar" ,"AddAddress": "Adicionar Endereço" diff --git a/locale/pt/js/db.js b/locale/pt/js/db.json similarity index 92% rename from locale/pt/js/db.js rename to locale/pt/js/db.json index 4769fd36..84f617e3 100644 --- a/locale/pt/js/db.js +++ b/locale/pt/js/db.json @@ -1,8 +1,7 @@ -Vn.Locale.add -({ +{ "ConnError": "Erro de conexão" ,"BadServerReply": "Resposta do servidor incorreta" ,"ModelNotUpdatable": "Este modelo não é actualizável" ,"RowNotExists": "O Registro não existe ou foi apagado" ,"ColNotExists": "A Coluna não existe" -}); +} diff --git a/locale/pt/js/hedera.js b/locale/pt/js/hedera.json similarity index 98% rename from locale/pt/js/hedera.js rename to locale/pt/js/hedera.json index 18b17f53..06cbd297 100644 --- a/locale/pt/js/hedera.js +++ b/locale/pt/js/hedera.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "User": "Usuario" ,"Password": "Palavra-Passe" ,"Beta": "Beta" @@ -56,4 +55,4 @@ Vn.Locale.add ,"Configuration": "Configuração" ,"Account": "Conta" ,"Addresses": "Endereços" -}); +} diff --git a/locale/pt/js/htk.js b/locale/pt/js/htk.json similarity index 97% rename from locale/pt/js/htk.js rename to locale/pt/js/htk.json index c0e2329b..65a2d556 100644 --- a/locale/pt/js/htk.js +++ b/locale/pt/js/htk.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "True": "Sim" ,"False": "Não" ,"Null": "Nulo" @@ -28,4 +27,4 @@ Vn.Locale.add ,"Next": "Seguinte" ,"Search": "Procurar" ,"Search...": "Procurar..." -}); +} diff --git a/locale/pt/js/vn.js b/locale/pt/js/vn.json similarity index 97% rename from locale/pt/js/vn.js rename to locale/pt/js/vn.json index eb2edcad..d236b833 100644 --- a/locale/pt/js/vn.js +++ b/locale/pt/js/vn.json @@ -1,5 +1,4 @@ -Vn.Locale.add -({ +{ "Sunday": "Domingo" ,"Monday": "Segunda-Feira" ,"Tuesday": "Terça-Feira" @@ -43,4 +42,4 @@ Vn.Locale.add ,"Dec": "Dez" ,"%A, %B %e": "%A, %B %e" -}); +} diff --git a/package.json b/package.json index 6c101f34..a261580e 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "devDependencies": { "webpack": "*", "webpack-dev-server": "*", + "split-by-name-webpack-plugin": "*", "css-loader": "*", "style-loader": "*", "file-loader": "*", diff --git a/webpack.config.js b/webpack.config.js index 36d29e30..6107dab8 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,4 +1,5 @@ +var fs = require ('fs'); var webpack = require ('webpack'); module.exports = @@ -24,7 +25,26 @@ module.exports = fallback: process.env.NODE_PATH }, plugins: [ - /*new webpack.optimize.UglifyJsPlugin ({minimize: true})*/ - ] +/* new webpack.IgnorePlugin (new RegExp ('.{2}/(forms|pages|rest)')) + new webpack.optimize.UglifyJsPlugin ({minimize: true}) +*/ ] }; +/* +var configs = []; +var langs = fs.readdirSync ('./locale'); +for (var lang in languages) +configs.push ( +{ + entry: './locale.js', + output: { + path: __dirname +'/build', + filename: 'lang.'+ lang +'.js' + }, + module: { + loaders: [ + { test: /\.json$/, loader: 'json' } + ] + } +}); +*/