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

SitePoint PHP Blog:
How to Dynamically Localize TinyMCE
Dec 02, 2013 @ 16:37:41

The SitePoint PHP blog has a post from Roland Clemenceau about localizing the TinyMCE editor, a web-based Javascript HTML WYSIWYG editor. It's dropped in to make textareas rich-text editing components of your page quickly and easily.

This tutorial assumes you have built a PHP multilingual site/framework and you, or whoever the admin is, would like TinyMCE to automatically switch to the current language of your site. [...] Although TinyMCE is a great wysiwyg editor that provides localized files for almost every known language, it still does not come with an automatic language-switching feature. It's very easy to roll your own solution to this problem, though, so that's what we're going to do now.

He shows how to use extra language files in coordination with a "language" setting. This setting (usually something like "en" or "es") can then be set as a configuration option when the TinyMCE instance is added to the page.

tagged: localize tinymce editor wysiwyg tutorial html

Link: http://www.sitepoint.com/dynamically-localize-tinymce/

PHPMaster.com:
Localizing PHP Applications "The Right Way", Part 5
Nov 25, 2011 @ 20:58:09

PHPMaster.com has posted the fifth part of their "Localizing PHP Applications 'The Right Way'" series, this time with a focus on extracting data from the .pot template files to define in your PHP. (This is the final part of the series.)

In Part 4 you learned how to use gettext for one of the most complex aspects of localization a developer can face, plural forms. In this, the final part of the five-part series, I’ll teach you how you to automate part of the localization process by extracting msgids and generating a PO template file (.pot) from your application’s PHP code.

They show how to use the xgettext command-line tool to pull out strings from your source and automatically make them into a domain template. They help you set up three sample PHP files and run the xgettext command on them to pull out messages defined in the text of the files to set up keys in the template. Screenshots are included showing how to use Poedit to use these templates for your new translations.

tagged: localize xgettext tutorial gettext extract

Link:

PHPMaster.com:
Localizing PHP Applications "The Right Way", Part 4
Nov 21, 2011 @ 16:58:31

In the latest installment of their "Localizing PHP Applications 'The Right Way'" tutorial series (part four), they show off a feature of gettext that makes it simpler to deal with singular versus plural versions of your translations.

In Part 3 you learned some of the more important aspects of real-world localizing your application, such as using a default fallback locale and separating messages into multiple domain files depending on their usage. In this part I’ll show you what is arguably the most powerful feature of gettext – handling plural forms. The plural forms feature of gettext you enable you to localize your application perfectly and professionally.

The simple example they give is the difference between things like "1 file" versus "2 files". English is simpler than some other languages but gettext has special handling you can add to your translation files to help. A rule placed at the top of your file defines where to start the singular vs plural switch.

tagged: localize application plural singular

Link:

PHPMaster.com:
Localizing PHP Applications "The Right Way", Part 3
Nov 14, 2011 @ 14:38:48

PHPMaster.com has posted its third part of its "Localizing PHP Applications 'The Right Way'" series. In this third part you'll learn more about locales and message domain switching.

In Part 2 you gained more insight into using the gettext library by learning the most important functions of the extension. In this part you’ll learn how to best use a fallback locale, switch between locales, and override the currently selected message domain.

They show you how to set up the directory structure to handle a fallback locale, a choice to use when the system can't determine which to use. By using a default, you also avoid having the system translate from the default language to...the default language (like "English" to "English"). Included are also the code bits you'll need to switch between locales (just using a different domain) and using the dgettext function to specify a different domain than the selected one.

tagged: localize application gettext domain locale series part3

Link:

PHPMaster.com:
Localizing PHP Applications "The Right Way", Part 2
Nov 02, 2011 @ 20:05:03

PHPMaster.com has posted the second part of their series about localizing PHP applications "the right way" (hint: it uses gettext).

Welcome back to this series of articles which teach you how to localize your PHP applications using gettext and its PHP extension. In Part 1 you took your first steps towards towards this by installing gettext and Poedit, creating a translation file, and writing a Hello World script. In this part you’ll lean about each of the function used in the script, and dive more into the gettext library and its usage.

The explain some of the naming conventions gettext uses for things (like "domains" and "codeset") as well as the shorthand "_()" you can use to retrieve translated values. There's also a look at supporting multiple locales via multiple directories of .po and .mo files.

tagged: localize application gettext poedit series part2

Link:

PHPMaster.com:
Localizing PHP Applications "The Right Way", Part 1
Oct 31, 2011 @ 13:38:25

PHPMaster.com has a new tutorial sharing what they call the right way for localizing PHP applications with the help of PHP's gettext functionality.

Localizing software applications in general used to be a cumbersome and error-prone task resulting in a lot of messy code. Some developers even use different versions of code for the same application but for different locales, which makes managing the codebase practically impossible. Enter gettext, the wonderful open-source tool that will make your life easier by allowing you to concentrate on your code. Localization becomes a matter of writing separate translation files for the target language, which can easily be done by a translator using Poedit.

They help you get your environment set up - PHP and a href="http://poedit.net/">Poedit, a gettext catalog editor - for both linux- and Windows-based OSes. They walk you through the creation of a simple project and a few basic "hello world" tokens. Using the files is as easy as setting the correct locale and default domain for your application. Then output is just a basic echo away.

tagged: localize application gettext poedit series part1

Link:

WebReference.com:
Create a Localized Web Page with PHP
Oct 21, 2010 @ 18:21:23

On WebReference.com there's a new tutorial posted about localizing your website by defining a character set to use for your content.

The process of making your applications/websites usable in many different locales is called internationalization, While customizing your code for different locales is called localization. Localization is the process of making your applications or websites local to where it is being viewed. For example, you can make a website more local to a particular place by converting its text to the predominate language of that location and by displaying the local time (e.g. German for people living in Germany or French for people living in France).

They show how to define constants that can be used in your application for the character set and language encoding. They use two major encodings - UTF-8 and ISO-8859-1 - in their examples of showing a sample "welcome" message in different languages. There's also a simple page to show you how to switch between languages if you'd like to give your visitors the option.

tagged: localize tutorial language encoding character

Link:

PHPBuilder.com:
Localizing a Web Page for Different Languages
Oct 11, 2006 @ 20:36:00

PHPBuilder.com excerpts once again from the Sams Publishing book "PHP 5 in Practice" today with this new tutorial showing a method for localizing web pages for different languages.

Internationalization and localization of a web page is simply the act of setting it up to be able to handle displaying in multiple languages and adding those different languages in. There are many different ways in which to do this. One of the simplest is to just make sure that all your strings that you ever output are stored as variables or constants in an included file. That way, you can make multiple copies of that file,each with different language versions written into them. Just include the appropriate file for the language that you want to display.

They show the creation of the different language PHP files that will be included and the master "language.php" that works with the under's input to switch to the correct language (and set a cookie to save the preference).

tagged: localize different language page include cookie localize different language page include cookie

Link:

PHPBuilder.com:
Localizing a Web Page for Different Languages
Oct 11, 2006 @ 20:36:00

PHPBuilder.com excerpts once again from the Sams Publishing book "PHP 5 in Practice" today with this new tutorial showing a method for localizing web pages for different languages.

Internationalization and localization of a web page is simply the act of setting it up to be able to handle displaying in multiple languages and adding those different languages in. There are many different ways in which to do this. One of the simplest is to just make sure that all your strings that you ever output are stored as variables or constants in an included file. That way, you can make multiple copies of that file,each with different language versions written into them. Just include the appropriate file for the language that you want to display.

They show the creation of the different language PHP files that will be included and the master "language.php" that works with the under's input to switch to the correct language (and set a cookie to save the preference).

tagged: localize different language page include cookie localize different language page include cookie

Link:


Trending Topics: