2. Table of content
1. Why Gettext?
2. Applying to a PHP project
3. Converting text
4. Multi-language for images & a static page
5. Multi-language for Javascript files
6. Translating with parameters
7. Group translations by domain
8. Multi-language for Guess & Logged Users
9. Using POEdit
2
3. 1. Why Gettext
• Encode and compress messages in binary
format
• Support by almost popular programming
languages (C, C++, Java, Python, Objective C,
C#, etc)
• Support translating text in Singular/Plural
form
• Powerful tool: POEdit
3
4. 2. Applying to a PHP project
• Put the code below into entry PHP script
require_once("locale/bootstrap.php");
• Edit config.php to match your need
• Translated message files are laid at:
locale/{langcode}/LC_MESSAGES/{domain}.po
4
5. 3. Converting text
• Text in PHP scripts
<?php
$msg = _t(“This is a message for translation”);
echo $msg;
• Text in HTML files
<p>
<span><?php echo _t(“This is a span text”);?></span>
</p>
5
6. 4. Multi-language for images & static
pages
• With images
<img src=“/path/to/image/<?php echo _t(“banner.png”);?>”/>
• With static pages
<h2><?php echo _t(“My CMS Page”);?></h2>
<?php include(_t(“cms_page.phtml”));?>
6
8. 6. Translating with parameters
<?php
$msg = _t(“This photo has {comments} {commentText}”, array(
“{comments}” => $totalComments,
“{commentText} => _p(“comment", “comments", $totalComments)
));
echo $msg;
If $totalComments = 5, this will output:
This photo has 5 comments
8
9. 7. Group translations by domain
To enable domain translation, do following steps:
1. Define domain translation function in function.php
2. Create translation file and enable function name as keyword
for extracting text
3. Use POEdit for extracting text
9
10. 8. Multi-language for Guess & Logged
Users
• This library using cookie for keeping user’s preferred
language
• Already enabled for Guess
• Enabling multi-language for logged users by adding following
script after bootstrap.php is loaded
<?php
require_once("locale/bootstrap.php");
// some code for getting user’s language code
putenv("LANGUAGE={$userLangCode}");
10
This template can be used as a starter file for presenting training materials in a group setting.SectionsRight-click on a slide to add sections. Sections can help to organize your slides or facilitate collaboration between multiple authors.NotesUse the Notes section for delivery notes or to provide additional details for the audience. View these notes in Presentation View during your presentation. Keep in mind the font size (important for accessibility, visibility, videotaping, and online production)Coordinated colors Pay particular attention to the graphs, charts, and text boxes.Consider that attendees will print in black and white or grayscale. Run a test print to make sure your colors work when printed in pure black and white and grayscale.Graphics, tables, and graphsKeep it simple: If possible, use consistent, non-distracting styles and colors.Label all graphs and tables.
Give a brief overview of the presentation. Describe the major focus of the presentation and why it is important.Introduce each of the major topics.To provide a road map for the audience, you can repeat this Overview slide throughout the presentation, highlighting the particular topic you will discuss next.