phphtmlinternationalizationmultiple-languages

Multiple languages using HTML5 data attribute


I have seen many ways to add multiple languages, I found one I like more than the others. Using HTML5 data-{string} they have added data-translate="USER_PROFILE"

Then they use a .json file like this:

{
    "PAGES": "Pages",
    "LOGIN": "Login",
    "LOG_OUT": "Logout",
    "SIGN_IN": "Sign In",
    "SIGN_UP": "Sign Up",
    "USER_PROFILE": "User Profile"
}

How to make that in PHP (database instead of .json) and HTML5 when using the data-something

I just think it will be easier to add new languages if it runs on the database, or are I'm wrong? What will be the best way??


Solution

  • The concept of multi language translation is called i18n. You will have to use some library for the same as implementing the whole part is a huge and daunting task. Here is something to get you started

    You will still have to create language files for the ones you need to support.