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 6643063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:00:18+00:00 2026-05-26T00:00:18+00:00

I’m curious what a good model structure is for a multilingual environment. I’ll use

  • 0

I’m curious what a good model structure is for a multilingual environment. I’ll use a products database as an example….

products
----------------------------------------------------------------
    products_id  |   products_customizer_id  |  date_added

products_description
----------------------------------------------------------------
    id  |  language_id  |  sku  |   description

I’d like to use getters and setters… I’m stuck with the question of, should I have 1 product model, or one for the description and other for products?

update
To be clear, I am forced to use this databse structure… I’m wondering how to setup my php models… I’d like to be able to do…

$product->setCustomizerId(4);
$product->setSku('BJKDJ423');
$product->setDescription('A spanish walrus');

$product->save();

And have it intelligently save each field in each database…. is this a good/bad idea, why or why not?

  • 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-05-26T00:00:19+00:00Added an answer on May 26, 2026 at 12:00 am

    That’s not too far off how I’d do it… I tend to stick to a format though like having all language specific tabled suffixed with _lang. So I’d have the 3 tables (using InnoDB with foreign keys for referential integrity).

    product
    ----------------------------------------------------------------
    id | ... fields ...
    
    
    language
    ----------------------------------------------------------------
    id | ... fields ...
    
    
    product_lang
    ----------------------------------------------------------------
    language_id | product_id | name | description | ... etc ...
    

    I’d probably use an ISO string for the language id, for example en-GB and an autoincremented INT for the product id. The primary key in the product_lang table would be a compound key created from the language_id and product_id fields – that way you avoid an unnecessary field and any INT constraints that would have.

    Otherwise yeah, you’re pretty much there.

    —- EDIT TO REFLECT UPDATED QUESTION —-

    OK – the model…

    Your model should reflect how you’ll be using it in a business sense rather than a database sense… I’d have a product model that wraps the data as you’ll use it so something like:

    class MyProduct {
      private $_id;
      private $_sku;
      private $_name;
      private $_description;
      ...
    
      public function setId($iId) {
        $this->_id = (int) $iId;
      }
    
      public function getId() {
        return $this->_id;
      }
    
      ... and so on ...
    }
    

    I’d set the language in the database connector, probably statically if you’re not changing it often, and have that pull the relevant data from the tables to propagate your object… I’m not a huge believer in active records – create object models that map business objects and a database that holds the data in a relational, normalised form. Use a database abstraction layer to convert one to the other.

    Aside on loading in the i18n settings

    Generally I’d store certain site-wide variables in a Singleton application object that’s loaded up on every page – that’s where I’d store the language id and all the application bootup stuff, so it’ll connect to the database, start the session, instantiate a user object, assign them a cart and so on and so forth – everything that’s used globally.

    Since the language will be set in that MyApp object and that object will also hold your database connector – you can simply have that object set the static MyDBConnector::setLang($sLang) parameter automatically on instantiation.

    This way, to kick up the entire application on any page, you need simply do something like

    require_once '/path/to/app.ini.php';
    $oApp = MyApp::getInstance();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a reasonable size flat file database of text documents mostly saved in
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.