Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8275655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:08:41+00:00 2026-06-08T08:08:41+00:00

UPDATE: I’ve come across this question I did after some years: now I know

  • 0

UPDATE: I’ve come across this question I did after some years: now I know this is a very bad approach. Please don’t use this. You can always use additional tables for i18n (for example products and products_lang), with separate entries for every locale: better for indexes, better for search, etc.


I’m trying to implement i18n in a MySQL/PHP site.

I’ve read answers stating that “i18n is not part of database normally”, which I think is a somewhat narrow-minded approach.
What about product namesd, or, like in my instance, a menu structure and contents stored in the db?

I would like to know what do you think of my approach, taking into account that the languages should be extensible, so I’m trying to avoid the “one column for each language solution”.

One solution would be to use a reference (id) for the string to translate and for every translatable column have a table with primary key, string id, language id and translation.

Another solution I thought was to use JSON. So a menu entry in my db would look like:

idmenu label
------ -------------------------------------------
5      {"en":"Homepage", "it":"pagina principale"}

What do you think of this approach?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:08:43+00:00Added an answer on June 8, 2026 at 8:08 am

    “One solution would be to use a reference (id) for the string to translate and for every translatable column have a table with primary key, string id, language id and translation.”

    I implemented it once, what i did was I took the existing database schema, looked for all tables with translatable text columns, and for each such table I created a separate table containing only those text columns, and an additional language id and id to tie it to the “data” row in the original table. So if I had:

    create table product (
      id          int          not null primary key
    , sku         varchar(12)  not null
    , price       decimal(8,2) not null
    , name        varchar(64)  not null
    , description text          
    )
    

    I would create:

    create table product_text (
      product_id  int          not null
    , language_id int          not null
    , name        varchar(64)  not null
    , description text
    , primary key (product_id, language_id)
    , foreign key (product_id) references product(id)
    , foreign key (language_id) references language(id)
    )
    

    And I would query like so:

    SELECT    product.id
    ,         COALESCE(product_text.name, product.name) name
    ,         COALESCE(product_text.description, product.description) description
    FROM      product
    LEFT JOIN product_text
    ON        product.id = product_text.product_id 
    AND       10         = product_text.language_id
    

    (10 would happen to be the language id which you’re interested in right now.)

    As you can see the original table retains the text columns – these serve as default in case no translation is available for the current language.

    So no need to create a separate table for each text column, just one table for all text columns (per original table)

    Like others pointed out, the JSON idea has the problem that it will be pretty impossible to query it, which in turn means being unable to extract only the translation you need at a particular time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UPDATE The second after I posted this question, thanks to the syntax highlighting of
UPDATE This is an old question for an old version of Xcode. It turned
UPDATE: I made a mistake in my debugging - this question is not relavent
UPDATE : A commenter told me to change some codes, this is the new
Update 2018 : This question was asked long before PostCSS existed, and I would
Update: Check out this follow-up question: Gem Update on Windows - is it broken?
Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
Update: Thanks for the suggestions guys. After further research, I’ve reformulated the question here:
UPDATE - No need to answer this now, I have solved below. Hi, I'm
UPDATE: QUESTION SOLVED! I realized that the reason for this is due to 'hoisting.'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.