Answer the question
In order to leave comments, you need to log in
Is it worth splitting translations between programming languages?
I am developing a multilingual project and came across a situation where a lot of js scripts are used with their own small phrases.
Initially, all translations are stored in the database, but sometimes there are situations when you just need to show a phrase that is packed in a js file.
Hence the question:
What is better, to store separate js translation files (ru.js, en.js, etc.) or register a php file: <script src="lang.php"></script>
in which to generate a js object with the necessary phrases in the desired language?
Answer the question
In order to leave comments, you need to log in
multilingualism eliminates hardcoding of phrases anywhere
you can create an object
var dictonary = {
ru: {
word1: "фраза 1",
word2: "фраза 2"
},
en: {
word1: "word 1",
word2: "word 2"
}
}
...dictonary[lang]['word2']...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question