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

Laravel News:
Laravel 5.7 Mail Localization Improvements
Oct 04, 2018 @ 14:18:41

In this new post to the Larvel News site, they cover some of the recent improvements in the mail handling for the framework, specifically in the use of localization to tailor the content for a certain language.

Laravel 5.7.7 is now released and includes both bug fixes and thanks to Derek MacDonald a big improvement to Mail Localization.

With the release of Laravel 5.7 the IlluminateNotificationsNotification class started offering a locale method to set the desired language. The application will change into this locale when the notification is being formatted and then revert back to the previous locale when formatting is complete.

The post provides an example of how to use this functionality in sending your emails and how to add a "locale" field to your models. This allows you to set up a preferred default locale for the data, removing the need to reference it directly every time.

tagged: mail localization improvement laravel tutorial example

Link: https://laravel-news.com/mail-localization

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/

Alain Schlesser:
Structuring PHP Exceptions
Oct 31, 2016 @ 15:46:25

Alain Schlesser has written up a new post for his site sharing some of his suggestions for structuring your PHP exceptions including localization, catching them and using them with named constructors.

I seem to constantly work on improving my habits regarding the use of exceptions. I think it is an area that I haven’t yet fully explored, and it is very difficult to find anything more than very basic explanations and tutorials online. While the consensus is to use exceptions, there is very little information on how to structure and manage them in a larger codebase. The larger and more complex your projects become, the more important it is to start with a proper structure to avoid expensive refactoring later on. Your client will surely be thankful!

In this article, I want to talk about the way I currently set them up and use them in PHP, in the hopes to spark some discussion on the topic and get further feedback.

He starts with a few thoughts about why even using exceptions is a good idea (over just errors) and how to build on the included SPL exception set. He then gets into the suggestions about:

  • naming conventions
  • using named constructors to encapsulate logic
  • working with localized exception messages
  • catching exceptions

He ends the post by suggesting one last piece that can help make catching and handling exceptions easier - a centralized handler, something potentially like BooBoo from The PHP League.

tagged: exception handling tutorial naming namedconstructors localization catching

Link: https://www.alainschlesser.com/structuring-php-exceptions/

TutsPlus.com:
Internationalizing WordPress Projects: Updates With WordPress 4.6
Oct 13, 2016 @ 17:07:47

TutsPlus.com has posted the latest in their "Internationalizing WordPress" series today, focusing on some of the changes that have come with the release of WordPress 4.6.

Throughout this series, we've covered exactly what you need to do to internationalize your WordPress projects. If you've not read any of the previous posts, I recommend checking them out.

Though there have been some changes to how internationalization and localization work in WordPress 4.6, that doesn't mean the previous tutorials are irrelevant. It just means that the way you opt to distribute your plugins and their localizations will change.

And that's what we're going to be covering in this tutorial.

You'll need to be caught up on the series before following along with this article. It defines some of the basics and gets your WordPress install in a certain state. Then they get into the changes with the WordPress update including a brief overview of how the internationalization and localization functionality now works and the idea of "just-in-time" translations.

tagged: wordpress update internnationalization localization version

Link: https://code.tutsplus.com/tutorials/internationalizing-wordpress-projects-updates-with-wordpress-46--cms-27155

SitePoint PHP Blog:
Localizing Dates, Currency, and Numbers with Php-Intl
May 23, 2016 @ 17:52:32

On the SitePoint PHP blog Younes Rafie has continued his series about the PHP "Intl" extension for use in internationalizing an application. in this second part of the series he moves away from just strings and looks at using it for currencies and numbers.

The first part of this series was an introduction of the PHP Intl extension and of how to localize your application’s messages. In this part, we’re going to learn about localizing numbers, dates, calendars, and similar complex data.

The post is broken down into a few different sections, each with their own examples:

  • Localizing Decimals
  • Localizing Currencies
  • Timezones
  • Calendars

The "Intl" extension makes these operations relatively simple with plenty of built-in objects and methods to help with the translations between the formats. You can find out more about this extension in the PHP manual.

tagged: date currency localization number tutorial intl extension series part2

Link: https://www.sitepoint.com/localizing-dates-currency-and-numbers-with-php-intl/

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/

Simon Holywell:
PHP date localisation with setlocale
Jul 21, 2015 @ 17:57:07

Simon Holywell as written up a tutorial for his site showing you how to use setlocale to do PHP date localization.

Localising sites can be a chore, but PHP has the venerable setlocale() to use system locales. These are like templates or profiles that describe how various types of data should be displayed. Should a price have a comma or point to indicate the decimals? When printing a date should PHP output Monday or Montag?

All of these considerations are locale specific and they map to a geographical area. Various cultures have their own standards for displaying this kind of information not to mention different languages to accommodate.

He shows how to find the locales your system supports and how to install them if the one(s) you need are missing. With it correctly installed, the system knows how to use it but PHP needs a little extra help. With a call to the setlocale method and the use of a special date string modifier (in this case "%B" for the month name) PHP knows to use the locale-aware version of the data...but only with strftime not the normal PHP date handling.

tagged: simonholywell setlocale locale localization strftime

Link: https://www.simonholywell.com/post/2015/07/php-date-setlocale-localisation/

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

Sebastian Bergmann's Blog:
Test Dependencies in PHPUnit 3.4
Nov 14, 2008 @ 16:25:20

Sebastian Bergmann talks about a new bit of functionality he's put into the 3.4 release of PHPUnit (the popular unit testing tool for PHP) based on a suggestion from a paper he'd read:

Back in July, I came across an academic paper (more academic papers on testing that I read recently) titled "JExample: Exploiting Dependencies Between Tests to Improve Defect Localization". [...] For the upcoming PHPUnit 3.4 I have implemented support for the idea expressed in the paper mentioned above.

The feature is a system that helps localize problems at the source, stripping away all of the cascading issues it might have tripped off, causing other tests to fail. This new feature (as illustrated by his code example using a DependencyFailureTest class) makes it simple to fail a test immediately whenever the scripts needs to via a fail() method. Check out the full post for the rest of the code and some further explanation on how it works.

tagged: phpunit test dependencies fail cascade source defect localization

Link:

Zend Developer Zone:
L10N==Localization (See there are ten letters...Oh, you get it...OK)
Jun 09, 2006 @ 11:57:37

Internationalization and Localization are concepts that all web sites and applications will have to deal with at some point. Why not design it form the start? Most people just don’t think about it but in an increasingly global society, you need to. The earlier you design for it, the easier it is to do.

They continue on in this post on the Zend Developer Zone with a resource to get you thinking - an Internationalization Primer from Johnathan Snook (as printed in Digital Web Magazine). He looks at the basics you'll need to know when putting in multi-language support, including database designs and precompiling.

tagged: localization article digital web magazine primer localization article digital web magazine primer

Link:


Trending Topics: