Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Pineco.de:
A Deeper Look at Laravel’s Localization
Jul 03, 2018 @ 18:22:31

On the Pineco.de site they've posted a new tutorial covering the use of Laravel's localization functionality to more easily develop multilingual applications.

Laravel’s localization functionality is a huge help when we are developing multilingual applications. But still there are some less known features, so let’s take a more in-depth look to explore them.

First of all, we wrote an article about pushing the translation mechanism to your front-end. Also, we have a package that covers all the functionality on the front-end for you. Now in this post, we will cover the array based localization, not the JSON one. If you are more interested in the JSON based translations, you can find the docs here.

They start with some of the basics of the helper functions Laravel provides to work with localization of strings and how to use "translation parameters". It then goes on to show examples of pluralization handling and finishes by mentioning a few other features for returning more translation data and the @lang Blade directive.

tagged: tutorial laravel localization i18n deeper look

Link: https://pineco.de/a-deeper-look-at-laravels-localization/

Pineco.de:
Simple Eloquent Model Translations
Jan 16, 2018 @ 15:41:46

On the Pineco.de blog there's a new post for the Laravel users out there showing you a simple way to integrate translations handling into your models. This functionality allows you to more easily build multilingual applications without having some of the overhead of a separate translation framework.

Making you models translatable could be an issue, especially if you are running an application that is multilingual. For static texts, we can use the built-in translation engine, but for models, we need to solve a more complex issue. Let’s take a look at a simple yet flexible solution.

While the post starts with a recommendation to use a full package if you need a more robust system, it quickly moves into the simpler structure they'll be defining. The tutorial describes the "translation mechanism" from a high level and includes the code to create the database table for holding the translated content. With that in place, next up is the model to connect the application with the table and a trait to house the translation logic. This is then used directly in the template (as a translation property) to fetch the translated version of the content.

tagged: eloquent model translation tutorial trait relation i18n

Link: https://pineco.de/simple-eloquent-model-translations/

TutsPlus.com:
Internationalizing WordPress Projects: A Practical Example, Part 1
Jul 06, 2016 @ 15:50:43

Tom McFarlin has continued his series covering internationalization in WordPress applications with this latest part of the series. In the previous part of the series he introduced some of the basic topics and terms. In this new tutorial he gets more into functionality creating the plugin he'll use in his examples.

Given that WordPress powers roughly 25% of the web and that the web is not local to your country of origin, it makes sense to ensure that the work that we produce can be translated into other locations.

To be clear, this does not mean that you, as the developer, are responsible for translating all of the strings in your codebase into the various languages that your customers may use. Instead, it means that you use the proper APIs to ensure someone else can come along and provide translations for them.

He then walks you through the download of the latest WordPress version (a Subversion checkout) and the creation of the plugin structure. He provides sample code to define the plugin and shows how it should look in the "Plugins" listing. He helps you add in the menu item with internationalized strings for the link text. They help you add a simple screen for the plugin and help you style the page a bit. The post ends with a brief mention of object-oriented programming but points out that OOP introduces other, not necessarily related, topics that could detract from the WordPress-related content (and so will not be used).

tagged: wordpress internationalization i18n tutorial series part2 plugin example practical

Link: http://code.tutsplus.com/tutorials/internationalizing-wordpress-projects-a-practical-example-part-1--cms-26676

SitePoint PHP Blog:
Localization Demystified: Php-Intl for Everyone
May 17, 2016 @ 14:44:39

The SitePoint PHP blog has posted a tutorial from Younes Rafie that wants to help demystify internationalization functionality in your PHP application...with the help from a handy extension, the intl extension.

Most applications perform locale aware operations like working with texts, dates, timezones, etc. The PHP Intl extension provides a good API for accessing the widely known ICU library’s functions.

He walks you through the installation of the extension if you don't have it already for both PHP 5 and PHP 7 (the second requires adding a custom apt-get repository). With that all installed and configured he starts in on the code to output a simple message with formatting using the MessageFormat functionality. His first example is in English but he also shows the difference between that and Arabic and Bengali and they're related output. He looks at a few other topics including pluralization, "choices" (different messages for different values) and more complex cases. He ends the post briefly looking at message parsing - extracting a value according to the provided format.

tagged: localization internationalization i18n messageformat intl extension tutorial

Link: https://www.sitepoint.com/localization-demystified-understanding-php-intl/

SitePoint PHP Blog:
Easy Multi-Language Twig Apps with Gettext
Apr 14, 2016 @ 17:55:08

The SitePoint PHP blog has a post from editor Bruno Skvorc showing you how to integrate gettext with Twig to make it easier to internationalize your application with multiple languages and strings.

There are many approaches for adding new languages to your application’s UI. Though some userland solutions like symfony/translation are arguably simpler to use, they’re slower than the good old native gettext by an order of several magnitudes.

In this tutorial, we’ll modify an English-only application to use gettext. Through this, we’ll demonstrate that getting internationalization up and running in an already existing app is not only possible, but relatively easy.

He starts with some of the bootstrapping you'll need to do to get the "nofw" project up, Twig installed and them hooked together. He briefly introduces gettext and how it's used in PHP (with the _() handling) and provides an example defining a locale and the language files to match. He shows how to generate the .pot files, add a new language and the code needed to hook in the Twig_Extensions_Extension_I18n extension. The post ends with some "bonus scripts" to help make things a bit simpler: bash scripts to hide some of the complexity of the process.

tagged: tutorial gettext internationalization i18n multilanguage language locale

Link: http://www.sitepoint.com/easy-multi-language-twig-apps-with-gettext/

NetTuts.com:
Localize Your Web Application for Any Country With the Google Translate API
May 04, 2015 @ 15:56:34

In this new tutorial to the NetTuts.com site author Jeff Reifman shows you how to use the Google Translate API to translate the content in your application/website to the language of your choosing. In his examples, he shows how to integrate it with a Yii framework application.

In this tutorial, I'll walk you through my extensions to the Yii I18n extract script which do exactly this. And I'll demonstrate translating my startup application, Meeting Planner, into a handful of languages. Keep in mind, Google Translate isn't perfect and it doesn't address issues related to time and date formats and currencies. But for a quick and affordable (free) way to build default translations for your web application into 50+ languages, this is an ideal solution.

He starts with a brief introduction to the Google Translate API, the languages it supports and how to install the library he's chosen to make the connection. He then gets into the internationalization (i18n) functionality that Yii has (an introduction to that is here) and how to define the "messages" files with the different content strings. These files are defined to there's no need to call out to the API for every piece of content that loads. He shows how to extend the message extraction handling to add in the API request and parsing the result. This information is then added to the current message information files, making it simpler to add in new strings. He then integrates this into the Meeting Planner application and shows how to run the script to call the Google API and switch the language with image results in several different languages of the finished output.

tagged: tutorial internationalization i18n googletranslate api yii framework messages

Link: http://code.tutsplus.com/tutorials/localize-your-web-application-for-any-country-with-the-google-translate-api--cms-23126

NetTuts.com:
Building Your Startup With PHP: Localization With I18n
Mar 09, 2015 @ 15:43:08

In the latest part of their series of "building a startup" application in PHP, NetTuts.com looks at supporting internationalization with the functionality of the Yii framework.

This is part four of the Building Your Startup With PHP series on Tuts+. In this series, I'm guiding you through launching a startup from concept to reality using my Meeting Planner app as a real life example. Every step along the way, we'll release the Meeting Planner code as open source examples you can learn from. We'll also address startup-related business issues as they arise. In this tutorial, I wanted to step back and add I18n internationalization support to our application before we build more and more code.

They start off with a look at some of the overall goals of internationalization (i18n) and about how it works in the Yii system. It uses placeholders with a key/value system to replace the data based on which language is selected. They show you how to configure Yii's support including default language, sorting of the data and files to exclude when looking for i18n configurations. With this configuration in place they show how to use the command line tool to extract these messages out into separate folders for easier management and faster reference. Finally they show how to select a language and use the Yii code generator together with the translations to create models and forms.

tagged: build startup series part4 internationalization i18n localization language yii framework

Link: http://code.tutsplus.com/tutorials/building-your-startup-with-php-localization-with-i18n--cms-23102

Lingohub.com:
Internationalization How To for the 5 most popular PHP frameworks
Jul 24, 2013 @ 15:15:31

On the Lingohub site there's a new post showing how internationalization (i18n) is handled in 5 major PHP frameworks - CodeIgniter, CakePHP, Zend Framework Symfony and Yii.

As discussed in the previous articles on PHP internationalization, PHP provides native support for string translation using gettext and PHP arrays. These can be used in any PHP project. Additionally, some popular PHP frameworks offer their own way of string translation. In this article, I want to provide a brief summary of the internationalization process with five of the most popular PHP frameworks currently out there. In this How-To you will read about using CodeIgniter, CakePHP, Zend, Yii and Symphony.

There's only a bit of sample code here, so it's not a complete tutorial for all of them. Mostly its links to more information about how each framework does things - modules used, formats and configurations.

tagged: framework i18n internationalization howto codeigniter zendframework symfony cakephp

Link: http://blog.lingohub.com/2013/07/internationalization-how-to-5-most-popular-php-frameworks

PHPMaster.com:
Internationalization Made Easy
Nov 12, 2012 @ 19:15:58

In this new tutorial posted to PHPMaster.com, Hari K T takes a look at internationalization in a Symfony2-based application using its own translation component.

If you’ve ever worked to develop a site which needed to be available in multiple languages then you know how difficult it can be. With the help of Symfony2′s Translation component you can easily make internationalized sites. I’ll show you how with some sample code and some discussion on its API.

He includes a basic example of how the component works with the typical "hello world" translation from English to French. He mentions fallback locales, pluralization and the conversion between translation formats (like converting from a YAML file into a translation object).

tagged: internationalization symfony2 i18n framework component tutorial

Link:

Anna Filina's Blog:
Doctrine Translation in leftJoin()
Apr 26, 2010 @ 16:39:33

In a recent post to his blog Anna Filina looks at internationalization in Doctrine and how Symfony auto-builds things to take care of it for you.

If you use Doctrine, then you probably know how lazy loading can hurt your performance. I carefully craft every query to everything that I need in one shot, but only what I need. One thing that evaded me at first was the i18n part. I am pleased with the way Doctrine + symfony magically creates all my models and database tables with i18n support.

She talks a bit about the internationalization (i18n) support is put into the schema.yml file and the bit of confusion she had over how to handle a left join using its structure. The key lies in the Translation relationships.

tagged: doctrine translation left join i18n internationalization

Link:


Trending Topics: