SlideShare una empresa de Scribd logo
1 de 38
Data Localization and Translation
Data Localization
and
Translation
Yevhen Shyshkin
yshyshkin@orocrm.com
https://github.com/yshyshkin
Data Localization and Translation
Language localisation is the process of
adapting a product that has been previously
translated into different languages to a
specific country or region.
What is language localization?
Data Localization and Translation
Where localization is applied?
- Name formatting
- Address formatting
- Datetime formatting
- Number formatting
- Decimal
- Integer
- Percent
- Currency
Data Localization and Translation
Localization configuration
System > Configuration > Localization
Data Localization and Translation
Localization configuration
$this->get('oro_locale.settings')->getLocale();
$this->get('oro_locale.settings')->getCurrency();
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Model/LocaleSettings.php
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Resources/public/js/locale-
settings.js
Result: en
USD
PHP:
JS: require(['orolocale/js/locale-settings'],
function(localeSettings) {
localeSettings.getLocale();
localeSettings.getCurrency();
});
Twig: {{ oro_locale() }}
{{ oro_currency() }}
Data Localization and Translation
Name formatting
- Names are formatted based on locale
- Name format configuration can be defined in
any bundle’s YAML file
Resources/config/oro/name_format.yml
- Format may contain placeholders for name
prefix, name suffix, first name,
last name and middle name
- Entity must include OroBundle
LocaleBundleModelFullNameInterface
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Model/FullNameInterface.php
Data Localization and Translation
Name formatting
en: %prefix% %first_name% %middle_name% %last_name% %suffix%
en_US: %prefix% %first_name% %middle_name% %last_name% %suffix%
ru: %last_name% %first_name% %middle_name%
ru_RU: %last_name% %first_name% %middle_name%
Configuration example
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Resources/config/oro/na
me_format.yml
Data Localization and Translation
Name formatting
$user = new User(); // implements FullNameInterface
$user->setNamePrefix('Mr.')
->setFirstName('John')
->setMiddleName('S.')
->setLastName('Doe')
->setNameSuffix('Jr.');
$this->get('oro_locale.formatter.name')->format($user);
$this->get('oro_locale.formatter.name')->format($user, 'ru');
PHP:
Twig: {{ entity|oro_format_name }}
{{ entity|oro_format_name('ru') }}
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Formatter/NameFormatter.php
Data Localization and Translation
Name formatting
require(['orolocale/js/formatter/name'],
function(nameFormatter) {
var user = {
'prefix': 'Mr.',
'first_name': 'John',
'middle_name': 'S.',
'last_name': 'Doe',
'suffix': 'Jr'
};
nameFormatter.format(user);
nameFormatter.format(user, 'ru');
});
JS:
Result: Mr. John S. Doe Jr.
Doe John S.
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Resources/public/js/formatter/na
me.js
Data Localization and Translation
Address formatting
- Addresses are formatted based on primary
location or country address
- Address format configuration can be defined in
any bundle’s YAML file
Resources/config/oro/address_format.yml
- Format may contain placeholders for name,
organization, street, city, region, region code,
country, country code and postal code
- Entity must include OroBundle
LocaleBundleModelAddressInterface
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Model/AddressInterface.php
Data Localization and Translation
Address formatting
US:
format: '%name%n%organization%n%street%n%CITY% %REGION_CODE%
%COUNTRY_ISO2% %postal_code%'
require: [street, city, region, postal_code]
zip_name_type: zip
region_name_type: region
RU:
format: '%postal_code% %COUNTRY%
%CITY%n%STREET%n%organization%n%name%'
require: [street, city, postal_code]
Configuration example
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Resources/config/oro/ad
dress_format.yml
Data Localization and Translation
Address formatting
$country = new Country('US');
$country->setName('United States of America')
->setIso3Code('USA');
$region = new Region('US-CA');
$region->setCode('CA')
->setName('California');
$address = new Address(); // implements AddressInterface
$address->setNamePrefix('Mr.')
->setFirstName('John')
->setMiddleName('S.')
->setLastName('Doe')
->setNameSuffix('Jr.');
$address->setStreet('Random str., 3, 14')
->setCity('Los Angeles')
->setRegion($region)
->setCountry($country)
->setPostalCode('12345')
->setOrganization('Oro Inc.');
$this->get('oro_locale.formatter.address')->format($address);
PHP:
Data Localization and Translation
Address formatting
Twig: {{ address|oro_format_address|nl2br }}
require(['orolocale/js/formatter/address'],
function(addressFormatter) {
var address = {
'prefix': 'Mr.',
'first_name': 'John',
'middle_name': 'S.',
'last_name': 'Doe',
'suffix': 'Jr',
'organization': 'Oro Inc.',
'street': 'Random str., 3, 14',
'city': 'Los Angeles',
'region_code': 'CA',
'country_iso2': 'US',
'postal_code': '12345'
};
addressFormatter.format(address);
});
JS:
Data Localization and Translation
Address formatting
Result: Mr. John S. Doe Jr.
Oro Inc.
Random str., 3, 14
LOS ANGELES CA US 12345
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Formatter/AddressFormatter.php
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Resources/public/js/formatter/addr
ess.js
Data Localization and Translation
Datetime formatting
- Datetime values are formatted based on locale,
timezone and type (none, short, medium, long,
full)
- Datetime format configuration extracted from
libicu via PHP INTL extension
- Datetime formatter accepts DateTime object,
string and timestamp values
Data Localization and Translation
Datetime formatting
PHP: $dateTime = new DateTime(
'2011-12-13 14:15:16',
new DateTimeZone('UTC')
);
$formatter = $this->get('oro_locale.formatter.date_time');
$formatter->format($dateTime);
$formatter->formatDate($dateTime->format('Y-m-d'));
$formatter->formatTime($dateTime->getTimestamp());
Result: Dec 13, 2011 4:15 PM
Dec 13, 2011
4:15 PM
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Formatter/DateTimeFormatter.php
Data Localization and Translation
Datetime formatting
JS: require(['orolocale/js/formatter/datetime'],
function(datetimeFormatter) {
datetimeFormatter.formatDateTime('2011-12-13T14:15:16+0000');
datetimeFormatter.formatDate('2011-12-13');
datetimeFormatter.formatTime('14:15:16');
});
Twig: {{ '2011-12-13 14:15:16'|oro_format_datetime }}
{{ '2011-12-13'|oro_format_date }}
{{ '14:15:16'|oro_format_time }}
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Resources/public/js/formatter/da
tetime.js
Result: Dec 13, 2011 4:15 PM
Dec 13, 2011
2:15 PM
Data Localization and Translation
Datetime format handling
- Different libraries use different datetime formats
- Oro Platform provides format converters for
libicu, moment.js and jquery.ui
- New formatters can be registered using DI tag
oro_locale.format_converter.date_time
Data Localization and Translation
Datetime timezone handling
- To simplify timezone handling all DateTime
object in the backend should be in UTC
timezone
- DateTime objects saved to the DB and
extracted from the DB are automatically
converted to UTC timezone
- Formatting of DateTime objects should be
performed using DateTimeConverter via
service oro_locale.formatter.date_time
Data Localization and Translation
Number formatting
- Numbers are formatted based on locale
- Formatter works with decimal, percent, currency,
spellout, duration and ordinal values
- Number format configuration extracted from
libicu via PHP INTL extension
- Currency use symbols from YAML files
Resources/config/oro/currency_data.yml
Data Localization and Translation
Number formatting
$formatter = $this->get('oro_locale.formatter.number');
$formatter->formatDecimal(12345.6789);
$formatter->formatDecimal(12345);
$formatter->formatPercent(1.2345);
$formatter->formatCurrency(12345.6789);
$formatter->formatCurrency(12345.6789, 'EUR');
PHP:
Twig: {{ 12345.6789|oro_format_decimal }}
{{ 12345|oro_format_decimal }}
{{ 1.2345|oro_format_percent }}
{{ 12345.6789|oro_format_currency }}
{{ 12345.6789|oro_format_currency({'currency':'EUR'}) }}
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Formatter/NumberFormatter.php
Data Localization and Translation
Number formatting
require(['orolocale/js/formatter/number'],
function(numberFormatter) {
numberFormatter.formatDecimal(12345.6789);
numberFormatter.formatInteger(12345);
numberFormatter.formatPercent(1.2345);
numberFormatter.formatCurrency(12345.6789);
numberFormatter.formatCurrency(12345.6789, 'EUR');
});
JS:
Result: 12,345.679
12,345
123.45%
$12,345.68
€12,345.68
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Resources/public/js/formatter/nu
mber.js
Data Localization and Translation
Localization CLI commands
oro:localization:dump - dump localization
configuration from YAML files to
web/js/oro.locale_data.js
Data Localization and Translation
Translation is the communication of the
meaning of a source-language text by
means of an equivalent target-language text.
What is translation?
Data Localization and Translation
Oro Platform use standard Symfony2 mechanism
to perform frontend translation in PHP, in Twig
templates, and translator.js library from
BazingaJsTranslationBundle
Translations are stored in YAML files in any bundle
and in the application database.
How translations used in
Oro Platform?
Data Localization and Translation
- messages - common messages used both for
system and custom purposes
- validators - validation messages
- jsmessages - messages translated on frontend
side
- tooltips - messages for and form field tooltips
- entity - data for entities translated with Gedmo
translatable extension
Translation domains
Data Localization and Translation
Recommended
translation message format
<application>.<bundle>.<section>.<key>
oro.user.form.choose_gender
oro.dataaudit.change_history.title
oro.entity_config.menu.entities_list.label
Format:
Examples:
Data Localization and Translation
Translation extractors
- PhpCodeExtractor - extracts formatted
strings from PHP code
- NavigationTranslationExtractor -
extracts title translations from
navigation.yml files
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/TranslationBundle/Extractor/PhpCodeEx
tractor.php
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/NavigationBundle/Title/TranslationExtrac
tor.php
Data Localization and Translation
Translation on backend
$this->get('translator')->trans('oro.dashboard.title.main');
$this->get('translator')->trans('oro.entity.item', ['%id%' => 42]);
PHP:
Twig: {{ 'oro.dashboard.title.main'|trans }}
{{ 'oro.entity.item'|trans({'%id%': 42}) }}
Result: Dashboard
Item #42
# messages.en.yml
oro.dashboard.title.main: "Dashboard"
oro.entity.item: "Item #%id%"
YAML:
Data Localization and Translation
Translation on frontend
require(['orotranslation/js/translator'],
function(__) {
__('oro.note.add_note_title');
__('oro.datagrid.pagination.totalRecords', {totalRecords: 42});
});
JS:
Result: Add note
Total of 42 records
# jsmessages.en.yml
oro.note.add_note_title: "Add note"
oro.datagrid.pagination:
totalRecords: "Total of {{ totalRecords }} records"
YAML:
Data Localization and Translation
Translation in the database
- table oro_translation
- entity OroTranslationBundle:Translation
- scopes SYSTEM and UI
# id
# key
# value
# locale
# domain
# scope
Translation
Data Localization and Translation
Translation in database
- OrmTranslationLoader - loads
translations from database
- DatabasePersister - persists translations
to database
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/TranslationBundle/Translation/Or
mTranslationLoader.php
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/TranslationBundle/Translation/Da
tabasePersister.php
Data Localization and Translation
Translation configuration
System > Configuration > Language settings
Data Localization and Translation
Interaction with Crowdin
- Dump translations from translation extractors
and YAML files
- Download translations from Crowdin
- Merge them with existing translations
- Upload updated translations to Crowdin
Oro Platform Crowdin
1. dump 2. download
3. merge
4. upload
Data Localization and Translation
Debug translator
- Wraps translated strings in square brackets -
[<string>]
- Wraps not translated strings into exclamation
marks - !!!---string---!!!
- Add JS prefix for frontend translations
- can be enabled in app/config/config.yml
oro_translation:
debug_translator: true
https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/TranslationBundle/Translation/De
bugTranslator.php
Data Localization and Translation
Debug translator
Data Localization and Translation
Translation CLI commands
oro:translation:dump - dumps frontend
translations into web/js/translation/<locale>.js
oro:translation:pack - extracts translation files
for each bundle in specified vendor namespace
and creates language pack
Data Localization and Translation
Questions
and
Answers

Más contenido relacionado

La actualidad más candente

JSP Standard Tag Library
JSP Standard Tag LibraryJSP Standard Tag Library
JSP Standard Tag LibraryIlio Catallo
 
Building Data Mapper PHP5
Building Data Mapper PHP5Building Data Mapper PHP5
Building Data Mapper PHP5Vance Lucas
 
What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3Jeremy Coates
 
Web Applications and Deployment
Web Applications and DeploymentWeb Applications and Deployment
Web Applications and DeploymentBG Java EE Course
 
JSP Standart Tag Lİbrary - JSTL
JSP Standart Tag Lİbrary - JSTLJSP Standart Tag Lİbrary - JSTL
JSP Standart Tag Lİbrary - JSTLseleciii44
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSCarol McDonald
 
JavaScript
JavaScriptJavaScript
JavaScriptSunil OS
 
JAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) BridgeJAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) BridgeJosé Paumard
 
8 Minutes On Rack
8 Minutes On Rack8 Minutes On Rack
8 Minutes On Rackdanwrong
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHPRob Knight
 
Web注入+http漏洞等描述
Web注入+http漏洞等描述Web注入+http漏洞等描述
Web注入+http漏洞等描述fangjiafu
 
03 form-data
03 form-data03 form-data
03 form-datasnopteck
 

La actualidad más candente (20)

Slim Framework
Slim FrameworkSlim Framework
Slim Framework
 
55 New Features in Java 7
55 New Features in Java 755 New Features in Java 7
55 New Features in Java 7
 
Jstl Guide
Jstl GuideJstl Guide
Jstl Guide
 
JSP Standard Tag Library
JSP Standard Tag LibraryJSP Standard Tag Library
JSP Standard Tag Library
 
Building Data Mapper PHP5
Building Data Mapper PHP5Building Data Mapper PHP5
Building Data Mapper PHP5
 
What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3
 
Web Applications and Deployment
Web Applications and DeploymentWeb Applications and Deployment
Web Applications and Deployment
 
JSP Standart Tag Lİbrary - JSTL
JSP Standart Tag Lİbrary - JSTLJSP Standart Tag Lİbrary - JSTL
JSP Standart Tag Lİbrary - JSTL
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RS
 
JavaScript
JavaScriptJavaScript
JavaScript
 
JAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) BridgeJAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) Bridge
 
PHP - Introduction to PHP Date and Time Functions
PHP -  Introduction to  PHP Date and Time FunctionsPHP -  Introduction to  PHP Date and Time Functions
PHP - Introduction to PHP Date and Time Functions
 
8 Minutes On Rack
8 Minutes On Rack8 Minutes On Rack
8 Minutes On Rack
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHP
 
Core Java - Quiz Questions - Bug Hunt
Core Java - Quiz Questions - Bug HuntCore Java - Quiz Questions - Bug Hunt
Core Java - Quiz Questions - Bug Hunt
 
Web注入+http漏洞等描述
Web注入+http漏洞等描述Web注入+http漏洞等描述
Web注入+http漏洞等描述
 
Wt unit 5
Wt unit 5Wt unit 5
Wt unit 5
 
03 form-data
03 form-data03 form-data
03 form-data
 
Java JDBC
Java JDBCJava JDBC
Java JDBC
 
Quebec pdo
Quebec pdoQuebec pdo
Quebec pdo
 

Similar a Data Localization and Translation

I18n
I18nI18n
I18nsoon
 
Internationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsInternationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsPierre MARTIN
 
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)James Titcumb
 
Zend framework 06 - zend config, pdf, i18n, l10n, sessions
Zend framework 06 - zend config, pdf, i18n, l10n, sessionsZend framework 06 - zend config, pdf, i18n, l10n, sessions
Zend framework 06 - zend config, pdf, i18n, l10n, sessionsTricode (part of Dept)
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with PerlDave Cross
 
Migrating from drupal to plone with transmogrifier
Migrating from drupal to plone with transmogrifierMigrating from drupal to plone with transmogrifier
Migrating from drupal to plone with transmogrifierClayton Parker
 
Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011Jacopo Romei
 
OWB11gR2 - Extending ETL
OWB11gR2 - Extending ETL OWB11gR2 - Extending ETL
OWB11gR2 - Extending ETL Suraj Bang
 
PHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4DevelopersPHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4DevelopersKacper Gunia
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
 
The Ruby On Rails I18n Core Api
The Ruby On Rails I18n Core ApiThe Ruby On Rails I18n Core Api
The Ruby On Rails I18n Core ApiNTT DATA Americas
 
Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hopeMarcus Ramberg
 
Rapid Prototyping with PEAR
Rapid Prototyping with PEARRapid Prototyping with PEAR
Rapid Prototyping with PEARMarkus Wolff
 
Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)
Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)
Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)James Titcumb
 
Internationalization with TYPO3
Internationalization with TYPO3Internationalization with TYPO3
Internationalization with TYPO3digiparden GmbH
 
How to Get Your Website Into the Cloud
How to Get Your Website Into the CloudHow to Get Your Website Into the Cloud
How to Get Your Website Into the CloudAll Things Open
 
Client-side JavaScript Vulnerabilities
Client-side JavaScript VulnerabilitiesClient-side JavaScript Vulnerabilities
Client-side JavaScript VulnerabilitiesOry Segal
 
Pyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web appsPyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web appsDylan Jay
 

Similar a Data Localization and Translation (20)

I18n
I18nI18n
I18n
 
Internationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsInternationalizing CakePHP Applications
Internationalizing CakePHP Applications
 
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
 
Zend framework 06 - zend config, pdf, i18n, l10n, sessions
Zend framework 06 - zend config, pdf, i18n, l10n, sessionsZend framework 06 - zend config, pdf, i18n, l10n, sessions
Zend framework 06 - zend config, pdf, i18n, l10n, sessions
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 
Migrating from drupal to plone with transmogrifier
Migrating from drupal to plone with transmogrifierMigrating from drupal to plone with transmogrifier
Migrating from drupal to plone with transmogrifier
 
Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011
 
OWB11gR2 - Extending ETL
OWB11gR2 - Extending ETL OWB11gR2 - Extending ETL
OWB11gR2 - Extending ETL
 
PHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4DevelopersPHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4Developers
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
The Ruby On Rails I18n Core Api
The Ruby On Rails I18n Core ApiThe Ruby On Rails I18n Core Api
The Ruby On Rails I18n Core Api
 
Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hope
 
Rapid Prototyping with PEAR
Rapid Prototyping with PEARRapid Prototyping with PEAR
Rapid Prototyping with PEAR
 
PHP and COM
PHP and COMPHP and COM
PHP and COM
 
Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)
Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)
Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)
 
Internationalization with TYPO3
Internationalization with TYPO3Internationalization with TYPO3
Internationalization with TYPO3
 
How to Get Your Website Into the Cloud
How to Get Your Website Into the CloudHow to Get Your Website Into the Cloud
How to Get Your Website Into the Cloud
 
Drupal 8 migrate!
Drupal 8 migrate!Drupal 8 migrate!
Drupal 8 migrate!
 
Client-side JavaScript Vulnerabilities
Client-side JavaScript VulnerabilitiesClient-side JavaScript Vulnerabilities
Client-side JavaScript Vulnerabilities
 
Pyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web appsPyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web apps
 

Más de Yevhen Shyshkin

Development Guide for Beginners
Development Guide for BeginnersDevelopment Guide for Beginners
Development Guide for BeginnersYevhen Shyshkin
 
Advanced Search with Elasticsearch
Advanced Search with ElasticsearchAdvanced Search with Elasticsearch
Advanced Search with ElasticsearchYevhen Shyshkin
 
E-Commerce search with Elasticsearch
E-Commerce search with ElasticsearchE-Commerce search with Elasticsearch
E-Commerce search with ElasticsearchYevhen Shyshkin
 
Code Review Best Practices
Code Review Best PracticesCode Review Best Practices
Code Review Best PracticesYevhen Shyshkin
 

Más de Yevhen Shyshkin (6)

Development Guide for Beginners
Development Guide for BeginnersDevelopment Guide for Beginners
Development Guide for Beginners
 
Advanced Search with Elasticsearch
Advanced Search with ElasticsearchAdvanced Search with Elasticsearch
Advanced Search with Elasticsearch
 
E-Commerce search with Elasticsearch
E-Commerce search with ElasticsearchE-Commerce search with Elasticsearch
E-Commerce search with Elasticsearch
 
Code Review Best Practices
Code Review Best PracticesCode Review Best Practices
Code Review Best Practices
 
Transactions etc
Transactions etcTransactions etc
Transactions etc
 
Oro Workflows
Oro WorkflowsOro Workflows
Oro Workflows
 

Último

%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 

Último (20)

%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 

Data Localization and Translation

  • 1. Data Localization and Translation Data Localization and Translation Yevhen Shyshkin yshyshkin@orocrm.com https://github.com/yshyshkin
  • 2. Data Localization and Translation Language localisation is the process of adapting a product that has been previously translated into different languages to a specific country or region. What is language localization?
  • 3. Data Localization and Translation Where localization is applied? - Name formatting - Address formatting - Datetime formatting - Number formatting - Decimal - Integer - Percent - Currency
  • 4. Data Localization and Translation Localization configuration System > Configuration > Localization
  • 5. Data Localization and Translation Localization configuration $this->get('oro_locale.settings')->getLocale(); $this->get('oro_locale.settings')->getCurrency(); https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Model/LocaleSettings.php https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Resources/public/js/locale- settings.js Result: en USD PHP: JS: require(['orolocale/js/locale-settings'], function(localeSettings) { localeSettings.getLocale(); localeSettings.getCurrency(); }); Twig: {{ oro_locale() }} {{ oro_currency() }}
  • 6. Data Localization and Translation Name formatting - Names are formatted based on locale - Name format configuration can be defined in any bundle’s YAML file Resources/config/oro/name_format.yml - Format may contain placeholders for name prefix, name suffix, first name, last name and middle name - Entity must include OroBundle LocaleBundleModelFullNameInterface https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Model/FullNameInterface.php
  • 7. Data Localization and Translation Name formatting en: %prefix% %first_name% %middle_name% %last_name% %suffix% en_US: %prefix% %first_name% %middle_name% %last_name% %suffix% ru: %last_name% %first_name% %middle_name% ru_RU: %last_name% %first_name% %middle_name% Configuration example https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Resources/config/oro/na me_format.yml
  • 8. Data Localization and Translation Name formatting $user = new User(); // implements FullNameInterface $user->setNamePrefix('Mr.') ->setFirstName('John') ->setMiddleName('S.') ->setLastName('Doe') ->setNameSuffix('Jr.'); $this->get('oro_locale.formatter.name')->format($user); $this->get('oro_locale.formatter.name')->format($user, 'ru'); PHP: Twig: {{ entity|oro_format_name }} {{ entity|oro_format_name('ru') }} https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Formatter/NameFormatter.php
  • 9. Data Localization and Translation Name formatting require(['orolocale/js/formatter/name'], function(nameFormatter) { var user = { 'prefix': 'Mr.', 'first_name': 'John', 'middle_name': 'S.', 'last_name': 'Doe', 'suffix': 'Jr' }; nameFormatter.format(user); nameFormatter.format(user, 'ru'); }); JS: Result: Mr. John S. Doe Jr. Doe John S. https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Resources/public/js/formatter/na me.js
  • 10. Data Localization and Translation Address formatting - Addresses are formatted based on primary location or country address - Address format configuration can be defined in any bundle’s YAML file Resources/config/oro/address_format.yml - Format may contain placeholders for name, organization, street, city, region, region code, country, country code and postal code - Entity must include OroBundle LocaleBundleModelAddressInterface https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Model/AddressInterface.php
  • 11. Data Localization and Translation Address formatting US: format: '%name%n%organization%n%street%n%CITY% %REGION_CODE% %COUNTRY_ISO2% %postal_code%' require: [street, city, region, postal_code] zip_name_type: zip region_name_type: region RU: format: '%postal_code% %COUNTRY% %CITY%n%STREET%n%organization%n%name%' require: [street, city, postal_code] Configuration example https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Resources/config/oro/ad dress_format.yml
  • 12. Data Localization and Translation Address formatting $country = new Country('US'); $country->setName('United States of America') ->setIso3Code('USA'); $region = new Region('US-CA'); $region->setCode('CA') ->setName('California'); $address = new Address(); // implements AddressInterface $address->setNamePrefix('Mr.') ->setFirstName('John') ->setMiddleName('S.') ->setLastName('Doe') ->setNameSuffix('Jr.'); $address->setStreet('Random str., 3, 14') ->setCity('Los Angeles') ->setRegion($region) ->setCountry($country) ->setPostalCode('12345') ->setOrganization('Oro Inc.'); $this->get('oro_locale.formatter.address')->format($address); PHP:
  • 13. Data Localization and Translation Address formatting Twig: {{ address|oro_format_address|nl2br }} require(['orolocale/js/formatter/address'], function(addressFormatter) { var address = { 'prefix': 'Mr.', 'first_name': 'John', 'middle_name': 'S.', 'last_name': 'Doe', 'suffix': 'Jr', 'organization': 'Oro Inc.', 'street': 'Random str., 3, 14', 'city': 'Los Angeles', 'region_code': 'CA', 'country_iso2': 'US', 'postal_code': '12345' }; addressFormatter.format(address); }); JS:
  • 14. Data Localization and Translation Address formatting Result: Mr. John S. Doe Jr. Oro Inc. Random str., 3, 14 LOS ANGELES CA US 12345 https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Formatter/AddressFormatter.php https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Resources/public/js/formatter/addr ess.js
  • 15. Data Localization and Translation Datetime formatting - Datetime values are formatted based on locale, timezone and type (none, short, medium, long, full) - Datetime format configuration extracted from libicu via PHP INTL extension - Datetime formatter accepts DateTime object, string and timestamp values
  • 16. Data Localization and Translation Datetime formatting PHP: $dateTime = new DateTime( '2011-12-13 14:15:16', new DateTimeZone('UTC') ); $formatter = $this->get('oro_locale.formatter.date_time'); $formatter->format($dateTime); $formatter->formatDate($dateTime->format('Y-m-d')); $formatter->formatTime($dateTime->getTimestamp()); Result: Dec 13, 2011 4:15 PM Dec 13, 2011 4:15 PM https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Formatter/DateTimeFormatter.php
  • 17. Data Localization and Translation Datetime formatting JS: require(['orolocale/js/formatter/datetime'], function(datetimeFormatter) { datetimeFormatter.formatDateTime('2011-12-13T14:15:16+0000'); datetimeFormatter.formatDate('2011-12-13'); datetimeFormatter.formatTime('14:15:16'); }); Twig: {{ '2011-12-13 14:15:16'|oro_format_datetime }} {{ '2011-12-13'|oro_format_date }} {{ '14:15:16'|oro_format_time }} https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Resources/public/js/formatter/da tetime.js Result: Dec 13, 2011 4:15 PM Dec 13, 2011 2:15 PM
  • 18. Data Localization and Translation Datetime format handling - Different libraries use different datetime formats - Oro Platform provides format converters for libicu, moment.js and jquery.ui - New formatters can be registered using DI tag oro_locale.format_converter.date_time
  • 19. Data Localization and Translation Datetime timezone handling - To simplify timezone handling all DateTime object in the backend should be in UTC timezone - DateTime objects saved to the DB and extracted from the DB are automatically converted to UTC timezone - Formatting of DateTime objects should be performed using DateTimeConverter via service oro_locale.formatter.date_time
  • 20. Data Localization and Translation Number formatting - Numbers are formatted based on locale - Formatter works with decimal, percent, currency, spellout, duration and ordinal values - Number format configuration extracted from libicu via PHP INTL extension - Currency use symbols from YAML files Resources/config/oro/currency_data.yml
  • 21. Data Localization and Translation Number formatting $formatter = $this->get('oro_locale.formatter.number'); $formatter->formatDecimal(12345.6789); $formatter->formatDecimal(12345); $formatter->formatPercent(1.2345); $formatter->formatCurrency(12345.6789); $formatter->formatCurrency(12345.6789, 'EUR'); PHP: Twig: {{ 12345.6789|oro_format_decimal }} {{ 12345|oro_format_decimal }} {{ 1.2345|oro_format_percent }} {{ 12345.6789|oro_format_currency }} {{ 12345.6789|oro_format_currency({'currency':'EUR'}) }} https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Formatter/NumberFormatter.php
  • 22. Data Localization and Translation Number formatting require(['orolocale/js/formatter/number'], function(numberFormatter) { numberFormatter.formatDecimal(12345.6789); numberFormatter.formatInteger(12345); numberFormatter.formatPercent(1.2345); numberFormatter.formatCurrency(12345.6789); numberFormatter.formatCurrency(12345.6789, 'EUR'); }); JS: Result: 12,345.679 12,345 123.45% $12,345.68 €12,345.68 https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/LocaleBundle/Resources/public/js/formatter/nu mber.js
  • 23. Data Localization and Translation Localization CLI commands oro:localization:dump - dump localization configuration from YAML files to web/js/oro.locale_data.js
  • 24. Data Localization and Translation Translation is the communication of the meaning of a source-language text by means of an equivalent target-language text. What is translation?
  • 25. Data Localization and Translation Oro Platform use standard Symfony2 mechanism to perform frontend translation in PHP, in Twig templates, and translator.js library from BazingaJsTranslationBundle Translations are stored in YAML files in any bundle and in the application database. How translations used in Oro Platform?
  • 26. Data Localization and Translation - messages - common messages used both for system and custom purposes - validators - validation messages - jsmessages - messages translated on frontend side - tooltips - messages for and form field tooltips - entity - data for entities translated with Gedmo translatable extension Translation domains
  • 27. Data Localization and Translation Recommended translation message format <application>.<bundle>.<section>.<key> oro.user.form.choose_gender oro.dataaudit.change_history.title oro.entity_config.menu.entities_list.label Format: Examples:
  • 28. Data Localization and Translation Translation extractors - PhpCodeExtractor - extracts formatted strings from PHP code - NavigationTranslationExtractor - extracts title translations from navigation.yml files https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/TranslationBundle/Extractor/PhpCodeEx tractor.php https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/NavigationBundle/Title/TranslationExtrac tor.php
  • 29. Data Localization and Translation Translation on backend $this->get('translator')->trans('oro.dashboard.title.main'); $this->get('translator')->trans('oro.entity.item', ['%id%' => 42]); PHP: Twig: {{ 'oro.dashboard.title.main'|trans }} {{ 'oro.entity.item'|trans({'%id%': 42}) }} Result: Dashboard Item #42 # messages.en.yml oro.dashboard.title.main: "Dashboard" oro.entity.item: "Item #%id%" YAML:
  • 30. Data Localization and Translation Translation on frontend require(['orotranslation/js/translator'], function(__) { __('oro.note.add_note_title'); __('oro.datagrid.pagination.totalRecords', {totalRecords: 42}); }); JS: Result: Add note Total of 42 records # jsmessages.en.yml oro.note.add_note_title: "Add note" oro.datagrid.pagination: totalRecords: "Total of {{ totalRecords }} records" YAML:
  • 31. Data Localization and Translation Translation in the database - table oro_translation - entity OroTranslationBundle:Translation - scopes SYSTEM and UI # id # key # value # locale # domain # scope Translation
  • 32. Data Localization and Translation Translation in database - OrmTranslationLoader - loads translations from database - DatabasePersister - persists translations to database https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/TranslationBundle/Translation/Or mTranslationLoader.php https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/TranslationBundle/Translation/Da tabasePersister.php
  • 33. Data Localization and Translation Translation configuration System > Configuration > Language settings
  • 34. Data Localization and Translation Interaction with Crowdin - Dump translations from translation extractors and YAML files - Download translations from Crowdin - Merge them with existing translations - Upload updated translations to Crowdin Oro Platform Crowdin 1. dump 2. download 3. merge 4. upload
  • 35. Data Localization and Translation Debug translator - Wraps translated strings in square brackets - [<string>] - Wraps not translated strings into exclamation marks - !!!---string---!!! - Add JS prefix for frontend translations - can be enabled in app/config/config.yml oro_translation: debug_translator: true https://github.com/orocrm/platform/blob/1.6.0/src/Oro/Bundle/TranslationBundle/Translation/De bugTranslator.php
  • 36. Data Localization and Translation Debug translator
  • 37. Data Localization and Translation Translation CLI commands oro:translation:dump - dumps frontend translations into web/js/translation/<locale>.js oro:translation:pack - extracts translation files for each bundle in specified vendor namespace and creates language pack
  • 38. Data Localization and Translation Questions and Answers