SlideShare ist ein Scribd-Unternehmen logo
1 von 12
MULTI-LANGUAGE FOR PHP
WITH GETTEXT
Binh Quan
2014-05-20
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
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
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
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
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
5. Multi-language for Javascript files
(Pending)
7
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
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
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
9. Using POEdit
• Preparing your .po file
• Setting source paths & keywords
• Extracting messages
• Perform translation
• Update changes
11
QUESTION?
12

Weitere ähnliche Inhalte

Was ist angesagt?

Livecode widget course
Livecode widget courseLivecode widget course
Livecode widget coursecrazyaxe
 
Presentation1
Presentation1Presentation1
Presentation1Twigsta
 
Function of PHP in Website Development
Function of PHP in Website DevelopmentFunction of PHP in Website Development
Function of PHP in Website DevelopmentEffOne_Technologies
 
PHP and Node.js-Differences and Similarities
PHP and Node.js-Differences and SimilaritiesPHP and Node.js-Differences and Similarities
PHP and Node.js-Differences and SimilaritiesCloud Analogy
 
The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189Mahmoud Samir Fayed
 
Don't Get Lost in Translation: Multilingual Site Building with Drupal 7 at Dr...
Don't Get Lost in Translation: Multilingual Site Building with Drupal 7 at Dr...Don't Get Lost in Translation: Multilingual Site Building with Drupal 7 at Dr...
Don't Get Lost in Translation: Multilingual Site Building with Drupal 7 at Dr...Suzanne Dergacheva
 
Learn PHP Lacture1
Learn PHP Lacture1Learn PHP Lacture1
Learn PHP Lacture1ADARSH BHATT
 
Top 10 php frameworks in 2021
Top 10 php frameworks in 2021Top 10 php frameworks in 2021
Top 10 php frameworks in 2021MaryamAnwar10
 
PHPCR - Standard Content Repository for PHP
PHPCR - Standard Content Repository for PHPPHPCR - Standard Content Repository for PHP
PHPCR - Standard Content Repository for PHPHenri Bergius
 
SERVER SIDE PROGRAMMING
SERVER SIDE PROGRAMMINGSERVER SIDE PROGRAMMING
SERVER SIDE PROGRAMMINGPrabu U
 
Web programming by kiran and team
Web programming by kiran and teamWeb programming by kiran and team
Web programming by kiran and teamHemanth Kumar N
 
Multilingual Drupal presentation from "Do it With Drupal"
Multilingual Drupal presentation from "Do it With Drupal"Multilingual Drupal presentation from "Do it With Drupal"
Multilingual Drupal presentation from "Do it With Drupal"Gábor Hojtsy
 
Server side programming
Server side programming Server side programming
Server side programming javed ahmed
 

Was ist angesagt? (20)

Livecode widget course
Livecode widget courseLivecode widget course
Livecode widget course
 
Presentation1
Presentation1Presentation1
Presentation1
 
Function of PHP in Website Development
Function of PHP in Website DevelopmentFunction of PHP in Website Development
Function of PHP in Website Development
 
C#
C#C#
C#
 
PHP and Node.js-Differences and Similarities
PHP and Node.js-Differences and SimilaritiesPHP and Node.js-Differences and Similarities
PHP and Node.js-Differences and Similarities
 
Tech talk webtech
Tech talk webtechTech talk webtech
Tech talk webtech
 
The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189
 
Don't Get Lost in Translation: Multilingual Site Building with Drupal 7 at Dr...
Don't Get Lost in Translation: Multilingual Site Building with Drupal 7 at Dr...Don't Get Lost in Translation: Multilingual Site Building with Drupal 7 at Dr...
Don't Get Lost in Translation: Multilingual Site Building with Drupal 7 at Dr...
 
Php
PhpPhp
Php
 
Learn PHP Lacture1
Learn PHP Lacture1Learn PHP Lacture1
Learn PHP Lacture1
 
Top 10 php frameworks in 2021
Top 10 php frameworks in 2021Top 10 php frameworks in 2021
Top 10 php frameworks in 2021
 
Wc13
Wc13Wc13
Wc13
 
PHPCR - Standard Content Repository for PHP
PHPCR - Standard Content Repository for PHPPHPCR - Standard Content Repository for PHP
PHPCR - Standard Content Repository for PHP
 
SERVER SIDE PROGRAMMING
SERVER SIDE PROGRAMMINGSERVER SIDE PROGRAMMING
SERVER SIDE PROGRAMMING
 
Web programming by kiran and team
Web programming by kiran and teamWeb programming by kiran and team
Web programming by kiran and team
 
4. features of .net
4. features of .net4. features of .net
4. features of .net
 
Dynamic language
Dynamic languageDynamic language
Dynamic language
 
Multilingual Drupal presentation from "Do it With Drupal"
Multilingual Drupal presentation from "Do it With Drupal"Multilingual Drupal presentation from "Do it With Drupal"
Multilingual Drupal presentation from "Do it With Drupal"
 
Spdy
SpdySpdy
Spdy
 
Server side programming
Server side programming Server side programming
Server side programming
 

Andere mochten auch

Number Series: How To Solve Questions with Short Tricks
Number Series: How To Solve Questions with Short TricksNumber Series: How To Solve Questions with Short Tricks
Number Series: How To Solve Questions with Short TricksEntrance Exam Info
 
"Internationalisation with PHP and Intl" source code
"Internationalisation with PHP and Intl" source code"Internationalisation with PHP and Intl" source code
"Internationalisation with PHP and Intl" source codeDaniel_Rhodes
 
Data localization and translation
Data localization and translationData localization and translation
Data localization and translationMotti Danino
 
Handling multibyte CSV files in PHP
Handling multibyte CSV files in PHPHandling multibyte CSV files in PHP
Handling multibyte CSV files in PHPDaniel_Rhodes
 
The Big Documentation Extravaganza
The Big Documentation ExtravaganzaThe Big Documentation Extravaganza
The Big Documentation ExtravaganzaStephan Schmidt
 
Problem Solving with Algorithms and Data Structures
Problem Solving with Algorithms and Data StructuresProblem Solving with Algorithms and Data Structures
Problem Solving with Algorithms and Data StructuresYi-Lung Tsai
 
Grand Rapids PHP Meetup: Behavioral Driven Development with Behat
Grand Rapids PHP Meetup: Behavioral Driven Development with BehatGrand Rapids PHP Meetup: Behavioral Driven Development with Behat
Grand Rapids PHP Meetup: Behavioral Driven Development with BehatRyan Weaver
 
People code events flowchart
People code events flowchartPeople code events flowchart
People code events flowchartSatish Ap
 
Internationalisation with PHP and Intl
Internationalisation with PHP and IntlInternationalisation with PHP and Intl
Internationalisation with PHP and IntlDaniel_Rhodes
 
Logical reasoning number series
Logical reasoning number seriesLogical reasoning number series
Logical reasoning number seriesPraveesh Palakeel
 
Computer Science Engineering : Data structure & algorithm, THE GATE ACADEMY
Computer Science Engineering : Data structure & algorithm, THE GATE ACADEMYComputer Science Engineering : Data structure & algorithm, THE GATE ACADEMY
Computer Science Engineering : Data structure & algorithm, THE GATE ACADEMYklirantga
 
Cmp104 lec 7 algorithm and flowcharts
Cmp104 lec 7 algorithm and flowchartsCmp104 lec 7 algorithm and flowcharts
Cmp104 lec 7 algorithm and flowchartskapil078
 
Data Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceData Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceTransweb Global Inc
 
Basics of computer science
Basics of computer scienceBasics of computer science
Basics of computer sciencePaul Schmidt
 
Computer Science & Information Systems
Computer Science & Information SystemsComputer Science & Information Systems
Computer Science & Information SystemsLuis Borges Gouveia
 

Andere mochten auch (20)

Php 2014 Projects_ S3 Infotech:09884848198.
Php  2014 Projects_ S3 Infotech:09884848198.Php  2014 Projects_ S3 Infotech:09884848198.
Php 2014 Projects_ S3 Infotech:09884848198.
 
Number Series: How To Solve Questions with Short Tricks
Number Series: How To Solve Questions with Short TricksNumber Series: How To Solve Questions with Short Tricks
Number Series: How To Solve Questions with Short Tricks
 
"Internationalisation with PHP and Intl" source code
"Internationalisation with PHP and Intl" source code"Internationalisation with PHP and Intl" source code
"Internationalisation with PHP and Intl" source code
 
Data localization and translation
Data localization and translationData localization and translation
Data localization and translation
 
Php Docs
Php DocsPhp Docs
Php Docs
 
Number series
Number seriesNumber series
Number series
 
Handling multibyte CSV files in PHP
Handling multibyte CSV files in PHPHandling multibyte CSV files in PHP
Handling multibyte CSV files in PHP
 
The Big Documentation Extravaganza
The Big Documentation ExtravaganzaThe Big Documentation Extravaganza
The Big Documentation Extravaganza
 
Problem Solving with Algorithms and Data Structures
Problem Solving with Algorithms and Data StructuresProblem Solving with Algorithms and Data Structures
Problem Solving with Algorithms and Data Structures
 
Grand Rapids PHP Meetup: Behavioral Driven Development with Behat
Grand Rapids PHP Meetup: Behavioral Driven Development with BehatGrand Rapids PHP Meetup: Behavioral Driven Development with Behat
Grand Rapids PHP Meetup: Behavioral Driven Development with Behat
 
People code events flowchart
People code events flowchartPeople code events flowchart
People code events flowchart
 
Internationalisation with PHP and Intl
Internationalisation with PHP and IntlInternationalisation with PHP and Intl
Internationalisation with PHP and Intl
 
Logical reasoning number series
Logical reasoning number seriesLogical reasoning number series
Logical reasoning number series
 
Computer Science Engineering : Data structure & algorithm, THE GATE ACADEMY
Computer Science Engineering : Data structure & algorithm, THE GATE ACADEMYComputer Science Engineering : Data structure & algorithm, THE GATE ACADEMY
Computer Science Engineering : Data structure & algorithm, THE GATE ACADEMY
 
Cmp104 lec 7 algorithm and flowcharts
Cmp104 lec 7 algorithm and flowchartsCmp104 lec 7 algorithm and flowcharts
Cmp104 lec 7 algorithm and flowcharts
 
Data Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceData Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer Science
 
Basics of computer science
Basics of computer scienceBasics of computer science
Basics of computer science
 
RSA Algorithm
RSA AlgorithmRSA Algorithm
RSA Algorithm
 
Computer Science & Information Systems
Computer Science & Information SystemsComputer Science & Information Systems
Computer Science & Information Systems
 
C Programming
C ProgrammingC Programming
C Programming
 

Ähnlich wie Multi language for php with gettext

Internationalizing and localizing wordpress theme
Internationalizing and localizing  wordpress themeInternationalizing and localizing  wordpress theme
Internationalizing and localizing wordpress themeSanjip Shah
 
Sanjip Shah: Internationalizing and Localizing WordPress Themes
Sanjip Shah: Internationalizing and Localizing  WordPress ThemesSanjip Shah: Internationalizing and Localizing  WordPress Themes
Sanjip Shah: Internationalizing and Localizing WordPress Themeswpnepal
 
07 response-headers
07 response-headers07 response-headers
07 response-headershanichandra
 
Desktop Apps with PHP and Titanium
Desktop Apps with PHP and TitaniumDesktop Apps with PHP and Titanium
Desktop Apps with PHP and TitaniumBen Ramsey
 
Barcelona Multilanguage
Barcelona MultilanguageBarcelona Multilanguage
Barcelona Multilanguageguest3a6661
 
Scripting languages presentation_michel_patrickfrancis
Scripting languages presentation_michel_patrickfrancisScripting languages presentation_michel_patrickfrancis
Scripting languages presentation_michel_patrickfrancisoloofrank
 
WordPress Theme & Plugin i18n & L10n
WordPress Theme & Plugin i18n & L10nWordPress Theme & Plugin i18n & L10n
WordPress Theme & Plugin i18n & L10ncodebangla
 
REST in Peace. Long live gRPC!
REST in Peace. Long live gRPC! REST in Peace. Long live gRPC!
REST in Peace. Long live gRPC! QAware GmbH
 
PHP Training: Module 1
PHP Training: Module 1PHP Training: Module 1
PHP Training: Module 1hussulinux
 
build your own php extension
build your own php extensionbuild your own php extension
build your own php extensionhazzaz
 
Integrating PHP With System-i using Web Services
Integrating PHP With System-i using Web ServicesIntegrating PHP With System-i using Web Services
Integrating PHP With System-i using Web ServicesIvo Jansch
 

Ähnlich wie Multi language for php with gettext (20)

Internationalizing and localizing wordpress theme
Internationalizing and localizing  wordpress themeInternationalizing and localizing  wordpress theme
Internationalizing and localizing wordpress theme
 
Sanjip Shah: Internationalizing and Localizing WordPress Themes
Sanjip Shah: Internationalizing and Localizing  WordPress ThemesSanjip Shah: Internationalizing and Localizing  WordPress Themes
Sanjip Shah: Internationalizing and Localizing WordPress Themes
 
07 response-headers
07 response-headers07 response-headers
07 response-headers
 
Desktop Apps with PHP and Titanium
Desktop Apps with PHP and TitaniumDesktop Apps with PHP and Titanium
Desktop Apps with PHP and Titanium
 
Barcelona Multilanguage
Barcelona MultilanguageBarcelona Multilanguage
Barcelona Multilanguage
 
Scripting languages presentation_michel_patrickfrancis
Scripting languages presentation_michel_patrickfrancisScripting languages presentation_michel_patrickfrancis
Scripting languages presentation_michel_patrickfrancis
 
How PHP works
How PHP works How PHP works
How PHP works
 
PHP
PHPPHP
PHP
 
WordPress Theme & Plugin i18n & L10n
WordPress Theme & Plugin i18n & L10nWordPress Theme & Plugin i18n & L10n
WordPress Theme & Plugin i18n & L10n
 
PHP ITCS 323
PHP ITCS 323PHP ITCS 323
PHP ITCS 323
 
REST in Peace. Long live gRPC!
REST in Peace. Long live gRPC! REST in Peace. Long live gRPC!
REST in Peace. Long live gRPC!
 
Php unit i
Php unit i Php unit i
Php unit i
 
Php intro
Php introPhp intro
Php intro
 
Wp Presentation
Wp PresentationWp Presentation
Wp Presentation
 
PHP Training: Module 1
PHP Training: Module 1PHP Training: Module 1
PHP Training: Module 1
 
build your own php extension
build your own php extensionbuild your own php extension
build your own php extension
 
PHP Course and Training
PHP Course and Training PHP Course and Training
PHP Course and Training
 
Php Training in Chandigarh
Php Training in ChandigarhPhp Training in Chandigarh
Php Training in Chandigarh
 
Integrating PHP With System-i using Web Services
Integrating PHP With System-i using Web ServicesIntegrating PHP With System-i using Web Services
Integrating PHP With System-i using Web Services
 
Php
PhpPhp
Php
 

Mehr von Binh Quan Duc

WordPress development checklist
WordPress development checklistWordPress development checklist
WordPress development checklistBinh Quan Duc
 
007. Redux middlewares
007. Redux middlewares007. Redux middlewares
007. Redux middlewaresBinh Quan Duc
 
006. React - Redux framework
006. React - Redux framework006. React - Redux framework
006. React - Redux frameworkBinh Quan Duc
 
005. a React project structure
005. a React project structure005. a React project structure
005. a React project structureBinh Quan Duc
 
004. Working with React component
004. Working with React component004. Working with React component
004. Working with React componentBinh Quan Duc
 
001. Introduction about React
001. Introduction about React001. Introduction about React
001. Introduction about ReactBinh Quan Duc
 
002. Working with Webpack
002. Working with Webpack002. Working with Webpack
002. Working with WebpackBinh Quan Duc
 
Git workflow step by step
Git workflow step by stepGit workflow step by step
Git workflow step by stepBinh Quan Duc
 
Introduction about type script
Introduction about type scriptIntroduction about type script
Introduction about type scriptBinh Quan Duc
 

Mehr von Binh Quan Duc (10)

WordPress development checklist
WordPress development checklistWordPress development checklist
WordPress development checklist
 
007. Redux middlewares
007. Redux middlewares007. Redux middlewares
007. Redux middlewares
 
006. React - Redux framework
006. React - Redux framework006. React - Redux framework
006. React - Redux framework
 
005. a React project structure
005. a React project structure005. a React project structure
005. a React project structure
 
004. Working with React component
004. Working with React component004. Working with React component
004. Working with React component
 
003. ReactJS basic
003. ReactJS basic003. ReactJS basic
003. ReactJS basic
 
001. Introduction about React
001. Introduction about React001. Introduction about React
001. Introduction about React
 
002. Working with Webpack
002. Working with Webpack002. Working with Webpack
002. Working with Webpack
 
Git workflow step by step
Git workflow step by stepGit workflow step by step
Git workflow step by step
 
Introduction about type script
Introduction about type scriptIntroduction about type script
Introduction about type script
 

Kürzlich hochgeladen

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
 
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
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
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
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
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
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 

Kürzlich hochgeladen (20)

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
 
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 🔝✔️✔️
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
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 🔝✔️✔️
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
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
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 

Multi language for php with gettext

  • 1. MULTI-LANGUAGE FOR PHP WITH GETTEXT Binh Quan 2014-05-20
  • 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
  • 7. 5. Multi-language for Javascript files (Pending) 7
  • 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
  • 11. 9. Using POEdit • Preparing your .po file • Setting source paths & keywords • Extracting messages • Perform translation • Update changes 11

Hinweis der Redaktion

  1. 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.
  2. 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.