PHP Multilanguage Class (PHPMLC)

PHP Multilanguage Class (PHPMLC)


PHP Multilanguage Class (PHPMLC) is a PHP class to add multilanguage feature to the projects/websites.

It comes with advanced administation panel to manage translations.
When the class initialized, it tries to automatically select browser language.
It is possible to switch prefered language anytime with the class methods.
The class uses MYSQL database to store translation data.
The session is also used to remember the last selected language even if the $_GET parameter is not specified.
All translated strings can be returned as an array. It is also possible to get translated string for specific key with the getTranslatedString() class method.
The class has caching feature so the need to query database on every request is eliminated.

Admin Panel Features

  • All pages are password protected
  • Admin can edit access credentials
  • Admin can manage languages
  • Admin can manage translations
  • Admin can manage panel languages
  • Admin can manage panel translations

Public Methods of the Class

  • setConnectionDetails()
  • getLastErrorMessage()
  • createTables()
  • getTranslatedStringsForCurrentLanguage()
  • getTranslatedString()
  • getTranslationKeys()
  • getLanguages()
  • getLanguageIds()
  • getLanguageDetailsByLanguageId()
  • setUseCache()
  • setTablePrefix()
  • getTablePrefix()
  • getCurrentLanguageId()
  • getCurrentLanguageCode()
  • getDefaultLanguageId()
  • getDefaultLanguageCode()
  • getUseCache()
  • setCurrentLanguage()
  • setCurrentLanguageById()
  • autoSelectCurrentLanguage()
  • clearCache()
  • All public methods are commented.


You can access online demo with the following links:

  • Sample Usage – Translation of “Welcome” message
  • Admin Panel

Please use following credentials to login admin panel:
username: admin
password: password

Please note that no changes are allowed in the demo mode.


PHP Multilanguage Class (PHPMLC) comes with full documentation.
From the installation to the usage you will feel like home.

Online documentation is also available.

Class Requirements

  • PHP 5.2 and above
  • MySQL 5.0 and above

In today’s technology, any modern web hosting company can provide you these requirements.

Change Log


  • first release.


  • add: dsn’s charset value.
  • add: connection’s MYSQL_ATTR_INIT_COMMAND attribute value.
  • updated documentation.


  • add: when the new language is added, the translations of the default language are copied to the newly added language.
  • add: caching support with setUseCache() method. (Please check example.php for its usage.)
  • performance update: updating translations is now faster.
  • several bug fixes.


  • bug fix: change in translation can’t be saved if the input field’s onchange event doesn’t occur.


  • several bug fixes.


  • bug fix: usage of undefined variable. (Thanks to J√≥zsef Nagy)


If you have a bug report or an improvement idea, feel free to comment about it.
I will try my best to provide you a good support.
I would also appreciate if you have time to review or rate the class too!



Author Image