i have a website that i built in two languages including two different "dictionaries" based on browser language
in each langXX.php i have
define('SOME_STRING', 'Some string');
etc... but i hate now this solution because i'm never sure if i included a new definition in both files...so i'm trying to move including all the definition in mysql and build a function like
translate('SOME_STRING', 'en'); // ouput 'Some string'
i'm moving to mysql because id like to manage the translation directly via a CMS i will build, i dont want to have the webmaster going trough ftp and textmate...
so my question is, if this latter solution i sbetter or is too stressful for mysql to get a query for each text element of the page..
PS. as far as i remember even osCommerce used this practice right?
Why WordPress is the Best Platform for Creating a Multilingual Website. WordPress isn't just the best way to make a multi language website because of its popularity – it also offers all the tools you need to quickly and easily translate your site into new languages.
Ways to add multi-language support to a website There are various ways to enable Multi-language support for an application. By having duplicate pages with the same content in the required languages. By managing language configuration (localization) with files containing texts in different languages.
lang_pl.php Add <meta > tag to set charset to utf8 . Create a <select > element with language options and create a <form> where use constant variables. Submit the language form when the option is selected from the <select> element. Initialize $_SESSION['lang'] with submitted language value and include a file.
Why not use file caching of the data stored in the database? You remove a potentially costly, heavily repeated set of database calls, but can retain the advantages of CMS overview of language values.
A simple method used to translate text elements of your website could be broken down into this simple three-table structure:
Language
--------
Id
Name # English, French, etc
Code # en-gb, fr, etc
# Text table stores content in the default language.
Text
----
Id
Content
# Translations relate to a language and an existing Text
Translation
-----------
FkText
FkLanguage
Content
This way, a simple query can obtain the requested content in any language, automatically falling back to default language if there is no translation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With