Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
How can we use properties file in js file

I wanted to use properties file in my js file i don't know how to do that This is my js file code

document.getElementById("Expedite").innerHTML = "Quickship Expedite : " + qsExpedPer
                                                + "%";

in place of innerHTML= "here" i want my properties file text how can i do this this is there any other method to do that What i am doing here is i want to change this Quickship Expedite in 9 languages i have different properties file for that but i dont know hoe to use properties file in js. someone please help.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

What you need to do is to use an object as a Map to contain your key value by language. Then you create a function to get the language value from it as follow:

/*Populate your hasmap*/
var languageMap={};


//for En language
languageMap["EN"] = {};
languageMap["EN"]["user"] = "User";
languageMap["EN"]["name"] = "Name";

//for FR language
languageMap["FR"] = {};
languageMap["FR"]["user"] = "Utilisateur";
languageMap["FR"]["name"] = "Nom";


//then you create a function to get the translation
function GetTransaltion(key, language){
    var hasLanguage = Object.keys(languageMap).includes(language);
    if(!hasLanguage){
        console.warn("The language " + language + " is not available");
        return key;
    }
    var haskey = Object.keys(languageMap[language]).includes(key);
    if(!haskey){
        console.warn("The key " + key + " is not available in language " + language);
        return key;
    }
    return languageMap[language][key];
}


//so when you get info from EN language of User you have 
GetTransaltion("user", "EN"); 

//so when you get info from FR language of User you have 
GetTransaltion("user", "FR"); 
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!