Hello ,
I got one JS that contains two “dictionaries”(they contain a key and the word that goes along with that key).
The problem is:
if i SET the variable for the dictionary by myself(in the JS where the dictionaries are) , all the words in the whole app will change , but if i storage.readSync(); the variable for the dictionary , first i need to rebuild the app and than the changes will happen.I call this JS with require(); in every other JS.
Hi Predrag,
would love to help, but can’t do anything without some code to look at. A complete, minimal reproduction that we can copy-paste and run would be nice.
I’m sorry
Here is the code from the dictionary:
var Observable = require('FuseJS/Observable');
var Storage = require("FuseJS/Storage");
var jazik = Observable();
var langFromStr = Storage.readSync("language");
console.log(langFromStr);
var jazici =
{
'en' :{
"loginText" : "Login",
"emailText" : "E-mail",
"password" : "Password",
"forgotPass" : "Forgot Password?",
"or" : "or",
"notReg" : "Not registered?",
"createAcc" : "Create account",
"resPass" : "Reset password",
"resPassTxt" : "We can help you reset your password using your email address linked to your account",
"verify" : "Verify",
"act" : "Activation",
"actTxt" : "A security code has been sent to your email address.Please enter the 6 digit security code below",
"secCode" : "Security code",
"notRecieve" : "Didn't recieve?",
"resend" : "Resend",
"newPass" : "New password",
"repPass" : "Repeat password",
"change" : "Change",
"ime" : "First name",
"prezime" : "Last name",
"phoneTxt" : "Phone",
"currencyTxt" : "Currency",
"languageTxt" : "Language",
"registerTxt" : "Register",
"editProfileTxt" : "Edit profile",
"aboutTxt" : "About",
"helpTxt" : "Help",
"editProfileTxt" : "Edit profile",
"typeTxt" : "Type account",
"colorTitle" : "Color",
"addAccTxt" : "Add account",
"addnameTxt" : "Add name",
"editTitle" : "Edit account"
},
'mk' : {
"loginText" : "Најава",
"emailText" : "Електронска пошта",
"password" : "Лозинка",
"forgotPass" : "Ја заборавивте лозинката?",
"or" : "или",
"notReg" : "Не сте регистрирани?",
"createAcc" : "Креирај профил",
"resPass" : "Обновете лозинка",
"resPassTxt" : "Можеме да Ви помогнеме да ја обновите лозинката со помош на Вашата електронска пошта",
"verify" : "Потврди",
"act" : "Активација",
"actTxt" : "Безбедносен код ќе биде испратен на Вашата електронска пошта",
"secCode" : "Безбедносен код",
"notRecieve" : "Не го добивте?",
"resend" : "Препрати",
"newPass" : "Нова лозинка",
"repPass" : "Повтори ја лозинката",
"change" : "Промени",
"ime" : "Име",
"prezime" : "Презиме",
"phoneTxt" : "Телефон",
"currencyTxt" : "Валута",
"languageTxt" : "Јазик",
"registerTxt" : "Регистрирај",
"editProfileTxt" : "Ажурирај профил",
"aboutTxt" : "Информации",
"helpTxt" : "Помош",
"editProfileTxt" : "Ажурирај профил",
"typeTxt" : "Тип сметка",
"colorTitle" : "Боја",
"addAccTxt" : "Додај сметка",
"addnameTxt" : "Додај име",
"editTitle" : "Ажурирај сметка"
}
}
jazik = jazici[langFromStr];
console.log(JSON.stringify(jazik));
module.exports = {
jazik : jazik
};
And here is the code from one JS:
var Observable = require('FuseJS/Observable');
var activeUrl = require("ApiCaller/ApiCaller.js");
var jazik = require("Constants/SetLanguage.js");
var Storage = require("FuseJS/Storage");
var email = Observable(null);
var password = Observable(null);
var flag = Observable();
var textToast = Observable();
var clientID = Observable();
var emailText = Observable();
var loginText = Observable();
var passwordPlc = Observable();
var forgotPass = Observable();
var loginBtn = Observable();
var or = Observable();
var notReg = Observable();
var createAcc = Observable();
emailText.value = jazik.jazik["emailText"];
loginText = jazik.jazik["loginText"];
passwordPlc = jazik.jazik["password"];
forgotPass = jazik.jazik["forgotPass"];
loginBtn = jazik.jazik["loginText"];
or = jazik.jazik["or"];
notReg = jazik.jazik["notReg"];
createAcc = jazik.jazik["createAcc"];
Even though,I solved this by adding in every page a dictionary for its own and it works,but that will make me pass my deadline , coz it’s a lot of work. Thank you for your time
One issue I immediately see is this:
// jazik is first an Observable:
var jazik = Observable();
// ...
// but then you replace the entire variable to be a simple object:
jazik = jazici[langFromStr];
That just can’t work.
As far as localization goes, we recommend taking this approach.
Hmmm , I saw the code , I think it will work.I was thinking about the same way of approach (with parsing), but I didn’t try it.However I am very thankful for your time.If there is an bigger issue I will post a thread.Thank you one more time.
It is working like charm.I had the same logic before, but mine had waaay longer code.Thank you for your time.