Step 7: Localization

Innomatic Platform supports localization and internationalization.

Localized strings are stored inside language specific catalogs, organized as INI files, with the following paths:

core/locale/catalogs/<app_name>/<language_identifier>/<catalog.ini>

To fetch the localized version of “panel_title” string in the “panel” catalog of the “example-basic-app” application for the current tenant user:

$container = \Innomatic\Core\InnomaticContainer::instance('\Innomatic\Core\InnomaticContainer');
$catalog = new \Innomatic\Locale\LocaleCatalog(
  ‘example-basic-app::panel’,
  $container->getCurrentUser()->getLanguage()
);
$label = $catalog->getStr(‘panel_title’);

A catalog is written as a standard INI file, e.g.:

examples          = Examples
example-basic-app = Basic App

You may also need to retrieve country-specific information, like decimal separator, currency symbol, time format, etc. or format a money amount:

$container = \Innomatic\Core\InnomaticContainer::instance('\Innomatic\Core\InnomaticContainer');
$country = new \Innomatic\Locale\LocaleCountry($container->getCurrentUser()->getCountry());
 
$decimalSeparator = $country->decimalSeparator();
$currencySymbol   = $country->currencySymbol();
$money            = $country->formatMoney(‘1200’);

Innomatic localization supports dates / times too with an interchangeable format (DateArray) for database, memory and user interface representation.

Retrieving a DateArray from database with a timestamp field type key:

$dateArray = $dataAccess->getDateArrayFromTimestamp($query->getFields(‘activitydate’));

Storing a DateArray in database:

$timeStamp = $dataAccess->getTimestampFromDateArray($dateArray);

Format a DateArray with the country settings:

$country = new \Innomatic\Locale\LocaleCountry($container->getCurrentUser()->getCountry());
$dateString = $country->formatArrayDate($dateArray);

Get a DateArray from a UNIX timestamp:

$dateArray = $country->getDateArrayFromUnixTimestamp($timeStamp);

Next: Step 8: Directories