When it comes to: [ Internationalization | globalization | localization ] one of the most popular standards is i18n . From the point of view of coding, we are talking about creating a "resource dictionary".
Different libraries have implemented this standard, and their principles span from translations to conversions when it comes to things like currencies, dates and numbers.
For example, i18n-js offers this structure:
I18n.translations = { en: { hello: "Hello World!" }, "pt-BR": { hello: "Olá Mundo!" }, "de": { hello: "Hallo Welt!" }, "nb": { hello: "Hei Verden!" } }; I18n.t("hello", {locale: "en"}); //returns "Hello World!" I18n.t("hello", {locale: "pt-BR"}); //returns "Olá Mundo!"
There is a jQuery plugin that can also help:
$.i18n.load({ a_key: 'translated string %2$s - %1$s' }); $.i18n._('a_key', ['order', 'in'])); //returns 'translated string in - order'
Conclusion
To determine the structure of your JSON, it is recommended that you first select a Framework that is best suited to your needs and follow the recommendations of the community. This will make decision-making more oriented and reinforced by community experience.
source share