SlideShare a Scribd company logo
1 of 12
Localizing a CakePHP Application
Presented By
What is Localization ?
It 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
Wrapping Translatable Text in __()
Functions
Supposing our menu looked like the following:
<ul>
<li>Send</li>
<li>Reply</li>
</ul>
We would wrap each text string inside the __() function
like as follows:
<ul>
<li><?php echo __('Send') ?></li>
<li><?php echo __('Reply') ?></li>
</ul>
● The __() function identifies these strings as
translatable text that will differ by language locale and
uses the text within the __() function as the message
ID. If we define the translations for a certain language,
those translations will appear in place of these
functions. If we do not define the translations for that
language, the text within the __() function will display
instead by default.
Creating the Localized PO Files
● The next step is to create the PO files which will contain
the translations for each language to be dynamically
inserted in each of the __() functions. CakePHP has two
ways you can do this: automatically using the console
shell; or manually.
Using the I18N Shell
CakePHP has some console shell programs that you can
run on the command line, including one to generate the PO
file to use as the original language source file for
translations. In our case it will be a file with all the English
text strings.
Creating the Localized PO Files
● To run the i18n shell command, type the following on the Linux
command line in your CakePHP application directory:
./Console/cake i18n extract
Then follow the onscreen menu.
The shell command will examine all of your application files
for instances of the __() function and generate a PO file for the
original source language that you can use to create the PO files
for each of the translations you are going to use.
Creating the PO Files Manually
● If you want to do this manually—for example you
don’t have many translatable text strings like in our
example—you can create the PO files by hand in a text
editor.
● First we will create the original source language
English version here:
● /app/Locale/eng/LC_MESSAGES/default.po
● The default.po file will have this format:
● msgid "ID"
● msgstr "STRING"
Creating the PO Files Manually
● Where msgid is the ID within the __() function; msgstr
is the localized translation that should appear as
output.
● Our full English source PO file will look like this:
msgid "Send"
msgstr "Send"
msgid "Reply"
msgstr "Reply"
Creating the PO Files Manually
● To create the Japanese localized version, we copy the
English PO file to the Japanese directory, and then
replace the English strings in the msgstr field with the
Japanese translations. (If you have a large application
being localized into dozens of languages, it is at this
point that you send the PO files to a language service
provider to translate the localized strings.)
● Our localized PO file with Japanese translations will
go here:
/app/Locale/jpn/LC_MESSAGES/default.po
Creating the PO Files Manually
● Our final localized Japanese PO file will look like this.
msgid "Send"
msgstr " 送信 "
msgid "Reply"
msgstr " 返信 "
● That’s it. The translations for English and Japanese will
display appropriately for the proper locale. If you want to
add translations for other languages, you do the same
process and put the new PO file in the directory that
corresponds with that language code.
Creating the PO Files Manually
● Our final localized Japanese PO file will look like this.
msgid "Send"
msgstr " 送信 "
msgid "Reply"
msgstr " 返信 "
● That’s it. The translations for English and Japanese will
display appropriately for the proper locale. If you want to
add translations for other languages, you do the same
process and put the new PO file in the directory that
corresponds with that language code.
● In your app Controller, inside before filter you need to
configure the language based on the region, It will be
as follows , Here am considering the japan as a
language . So based on the
● Configure::write('Config.language', 'jpn');

More Related Content

What's hot

Rebol brainwasher
Rebol brainwasherRebol brainwasher
Rebol brainwashercrazyaxe
 
Plone i18n, LinguaPlone
Plone i18n, LinguaPlonePlone i18n, LinguaPlone
Plone i18n, LinguaPloneQuintagroup
 
Python Intro For Managers
Python Intro For ManagersPython Intro For Managers
Python Intro For ManagersAtul Shridhar
 
PHP to Python with No Regrets
PHP to Python with No RegretsPHP to Python with No Regrets
PHP to Python with No RegretsAlex Ezell
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to phpSuraj Motee
 
ALPHA Script - Concept
ALPHA Script - ConceptALPHA Script - Concept
ALPHA Script - ConceptPROBOTEK
 
Lets Go - An introduction to Google's Go Programming Language
Lets Go - An introduction to Google's Go Programming Language Lets Go - An introduction to Google's Go Programming Language
Lets Go - An introduction to Google's Go Programming Language Ganesh Samarthyam
 
C introduction
C introductionC introduction
C introductionKamran
 

What's hot (14)

Php1
Php1Php1
Php1
 
Rebol brainwasher
Rebol brainwasherRebol brainwasher
Rebol brainwasher
 
Plone i18n, LinguaPlone
Plone i18n, LinguaPlonePlone i18n, LinguaPlone
Plone i18n, LinguaPlone
 
Php Vs Phyton
Php Vs PhytonPhp Vs Phyton
Php Vs Phyton
 
topic_perlcgi
topic_perlcgitopic_perlcgi
topic_perlcgi
 
Bottom-Line Web Services
Bottom-Line Web ServicesBottom-Line Web Services
Bottom-Line Web Services
 
Python Intro For Managers
Python Intro For ManagersPython Intro For Managers
Python Intro For Managers
 
Ruby, Meet iPhone
Ruby, Meet iPhoneRuby, Meet iPhone
Ruby, Meet iPhone
 
PHP to Python with No Regrets
PHP to Python with No RegretsPHP to Python with No Regrets
PHP to Python with No Regrets
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
ALPHA Script - Concept
ALPHA Script - ConceptALPHA Script - Concept
ALPHA Script - Concept
 
Lets Go - An introduction to Google's Go Programming Language
Lets Go - An introduction to Google's Go Programming Language Lets Go - An introduction to Google's Go Programming Language
Lets Go - An introduction to Google's Go Programming Language
 
Client side scripting
Client side scriptingClient side scripting
Client side scripting
 
C introduction
C introductionC introduction
C introduction
 

Viewers also liked

Jaws User Group in Ehime Lightning Talk
Jaws User Group in Ehime Lightning TalkJaws User Group in Ehime Lightning Talk
Jaws User Group in Ehime Lightning TalkKazuaki Ueda
 
Making bootable usb of ESXi-5.0
Making bootable usb of ESXi-5.0Making bootable usb of ESXi-5.0
Making bootable usb of ESXi-5.0Kazuaki Ueda
 
Android api-levels
Android api-levelsAndroid api-levels
Android api-levelsKazuaki Ueda
 
いろいろCMS勉強会 featuring SHIRASAGI
いろいろCMS勉強会 featuring SHIRASAGIいろいろCMS勉強会 featuring SHIRASAGI
いろいろCMS勉強会 featuring SHIRASAGIKazuaki Ueda
 
水曜デザイン塾 文字モジ会
水曜デザイン塾 文字モジ会水曜デザイン塾 文字モジ会
水曜デザイン塾 文字モジ会Kazuaki Ueda
 
Android multiscreen
Android multiscreenAndroid multiscreen
Android multiscreenKazuaki Ueda
 
Making bootable USB by update from 4.1 to 5.0
Making bootable USB by update from 4.1 to 5.0Making bootable USB by update from 4.1 to 5.0
Making bootable USB by update from 4.1 to 5.0Kazuaki Ueda
 
Android test tutorial
Android test tutorialAndroid test tutorial
Android test tutorialKazuaki Ueda
 
Pembelajaran berasaskan projek
Pembelajaran berasaskan projekPembelajaran berasaskan projek
Pembelajaran berasaskan projekHailmi Othman
 
Android Develop presentation on 19 Sep 2012.
Android Develop presentation on 19 Sep 2012.Android Develop presentation on 19 Sep 2012.
Android Develop presentation on 19 Sep 2012.Kazuaki Ueda
 
Android studio で行ってみよう!!
Android studio で行ってみよう!!Android studio で行ってみよう!!
Android studio で行ってみよう!!Kazuaki Ueda
 
Chalo Dilli
Chalo DilliChalo Dilli
Chalo Dillidilsegao
 
Kemahiran proses sains
Kemahiran proses sains Kemahiran proses sains
Kemahiran proses sains Hailmi Othman
 

Viewers also liked (19)

Jaws User Group in Ehime Lightning Talk
Jaws User Group in Ehime Lightning TalkJaws User Group in Ehime Lightning Talk
Jaws User Group in Ehime Lightning Talk
 
Making bootable usb of ESXi-5.0
Making bootable usb of ESXi-5.0Making bootable usb of ESXi-5.0
Making bootable usb of ESXi-5.0
 
Android api-levels
Android api-levelsAndroid api-levels
Android api-levels
 
Bidifydeb
BidifydebBidifydeb
Bidifydeb
 
いろいろCMS勉強会 featuring SHIRASAGI
いろいろCMS勉強会 featuring SHIRASAGIいろいろCMS勉強会 featuring SHIRASAGI
いろいろCMS勉強会 featuring SHIRASAGI
 
Ci tutorial
Ci tutorialCi tutorial
Ci tutorial
 
水曜デザイン塾 文字モジ会
水曜デザイン塾 文字モジ会水曜デザイン塾 文字モジ会
水曜デザイン塾 文字モジ会
 
Esxi client-4to5
Esxi client-4to5Esxi client-4to5
Esxi client-4to5
 
Android multiscreen
Android multiscreenAndroid multiscreen
Android multiscreen
 
Making bootable USB by update from 4.1 to 5.0
Making bootable USB by update from 4.1 to 5.0Making bootable USB by update from 4.1 to 5.0
Making bootable USB by update from 4.1 to 5.0
 
Android test tutorial
Android test tutorialAndroid test tutorial
Android test tutorial
 
Pembelajaran berasaskan projek
Pembelajaran berasaskan projekPembelajaran berasaskan projek
Pembelajaran berasaskan projek
 
Cms festa-0216
Cms festa-0216Cms festa-0216
Cms festa-0216
 
Android Develop presentation on 19 Sep 2012.
Android Develop presentation on 19 Sep 2012.Android Develop presentation on 19 Sep 2012.
Android Develop presentation on 19 Sep 2012.
 
Sudachi hackathon
Sudachi hackathonSudachi hackathon
Sudachi hackathon
 
Android studio で行ってみよう!!
Android studio で行ってみよう!!Android studio で行ってみよう!!
Android studio で行ってみよう!!
 
Modul edu3105
Modul edu3105Modul edu3105
Modul edu3105
 
Chalo Dilli
Chalo DilliChalo Dilli
Chalo Dilli
 
Kemahiran proses sains
Kemahiran proses sains Kemahiran proses sains
Kemahiran proses sains
 

Similar to Localization

languagetranslator-211028085026.pptx
languagetranslator-211028085026.pptxlanguagetranslator-211028085026.pptx
languagetranslator-211028085026.pptxMDASIFALI32
 
Computer languages
Computer languagesComputer languages
Computer languagesPrince Arsal
 
Lecture_1_Introduction_to_Programming.pptx
Lecture_1_Introduction_to_Programming.pptxLecture_1_Introduction_to_Programming.pptx
Lecture_1_Introduction_to_Programming.pptxChewe Lulembo
 
Language translator
Language translatorLanguage translator
Language translatorSumitSumit26
 
Preparing an Open Source Documentation Repository for Translations
Preparing an Open Source Documentation Repository for TranslationsPreparing an Open Source Documentation Repository for Translations
Preparing an Open Source Documentation Repository for TranslationsHPCC Systems
 
2 Programming Language.pdf
2 Programming Language.pdf2 Programming Language.pdf
2 Programming Language.pdfKINGZzofYouTube
 
Programming language
Programming languageProgramming language
Programming languagezeshmaiqbal
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to CompilersAkhil Kaushik
 
Multi Lingual Websites In Umbraco
Multi Lingual Websites In UmbracoMulti Lingual Websites In Umbraco
Multi Lingual Websites In UmbracoPaul Marden
 
Procedural Programming Of Programming Languages
Procedural Programming Of Programming LanguagesProcedural Programming Of Programming Languages
Procedural Programming Of Programming LanguagesTammy Moncrief
 
Program, Programming and Programming Language.pptx
Program, Programming and Programming Language.pptxProgram, Programming and Programming Language.pptx
Program, Programming and Programming Language.pptxHariharPaudel1
 
compilervsinterpreter-161008074915.pdf
compilervsinterpreter-161008074915.pdfcompilervsinterpreter-161008074915.pdf
compilervsinterpreter-161008074915.pdfHarshaVardhan196987
 

Similar to Localization (20)

Php packages
Php packagesPhp packages
Php packages
 
languagetranslator-211028085026.pptx
languagetranslator-211028085026.pptxlanguagetranslator-211028085026.pptx
languagetranslator-211028085026.pptx
 
Computer languages
Computer languagesComputer languages
Computer languages
 
Lecture_1_Introduction_to_Programming.pptx
Lecture_1_Introduction_to_Programming.pptxLecture_1_Introduction_to_Programming.pptx
Lecture_1_Introduction_to_Programming.pptx
 
Language translator
Language translatorLanguage translator
Language translator
 
Preparing an Open Source Documentation Repository for Translations
Preparing an Open Source Documentation Repository for TranslationsPreparing an Open Source Documentation Repository for Translations
Preparing an Open Source Documentation Repository for Translations
 
Assembler
AssemblerAssembler
Assembler
 
2 Programming Language.pdf
2 Programming Language.pdf2 Programming Language.pdf
2 Programming Language.pdf
 
Programming language
Programming languageProgramming language
Programming language
 
Moses
MosesMoses
Moses
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to Compilers
 
Multi Lingual Websites In Umbraco
Multi Lingual Websites In UmbracoMulti Lingual Websites In Umbraco
Multi Lingual Websites In Umbraco
 
Computer language
Computer languageComputer language
Computer language
 
Computer languages
Computer languagesComputer languages
Computer languages
 
Procedural Programming Of Programming Languages
Procedural Programming Of Programming LanguagesProcedural Programming Of Programming Languages
Procedural Programming Of Programming Languages
 
Program, Programming and Programming Language.pptx
Program, Programming and Programming Language.pptxProgram, Programming and Programming Language.pptx
Program, Programming and Programming Language.pptx
 
Lession 6
Lession 6Lession 6
Lession 6
 
Compiler vs interpreter
Compiler vs interpreter Compiler vs interpreter
Compiler vs interpreter
 
df
dfdf
df
 
compilervsinterpreter-161008074915.pdf
compilervsinterpreter-161008074915.pdfcompilervsinterpreter-161008074915.pdf
compilervsinterpreter-161008074915.pdf
 

Recently uploaded

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 

Recently uploaded (20)

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 

Localization

  • 1. Localizing a CakePHP Application Presented By
  • 2. What is Localization ? It 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
  • 3. Wrapping Translatable Text in __() Functions Supposing our menu looked like the following: <ul> <li>Send</li> <li>Reply</li> </ul> We would wrap each text string inside the __() function like as follows: <ul> <li><?php echo __('Send') ?></li> <li><?php echo __('Reply') ?></li> </ul>
  • 4. ● The __() function identifies these strings as translatable text that will differ by language locale and uses the text within the __() function as the message ID. If we define the translations for a certain language, those translations will appear in place of these functions. If we do not define the translations for that language, the text within the __() function will display instead by default.
  • 5. Creating the Localized PO Files ● The next step is to create the PO files which will contain the translations for each language to be dynamically inserted in each of the __() functions. CakePHP has two ways you can do this: automatically using the console shell; or manually. Using the I18N Shell CakePHP has some console shell programs that you can run on the command line, including one to generate the PO file to use as the original language source file for translations. In our case it will be a file with all the English text strings.
  • 6. Creating the Localized PO Files ● To run the i18n shell command, type the following on the Linux command line in your CakePHP application directory: ./Console/cake i18n extract Then follow the onscreen menu. The shell command will examine all of your application files for instances of the __() function and generate a PO file for the original source language that you can use to create the PO files for each of the translations you are going to use.
  • 7. Creating the PO Files Manually ● If you want to do this manually—for example you don’t have many translatable text strings like in our example—you can create the PO files by hand in a text editor. ● First we will create the original source language English version here: ● /app/Locale/eng/LC_MESSAGES/default.po ● The default.po file will have this format: ● msgid "ID" ● msgstr "STRING"
  • 8. Creating the PO Files Manually ● Where msgid is the ID within the __() function; msgstr is the localized translation that should appear as output. ● Our full English source PO file will look like this: msgid "Send" msgstr "Send" msgid "Reply" msgstr "Reply"
  • 9. Creating the PO Files Manually ● To create the Japanese localized version, we copy the English PO file to the Japanese directory, and then replace the English strings in the msgstr field with the Japanese translations. (If you have a large application being localized into dozens of languages, it is at this point that you send the PO files to a language service provider to translate the localized strings.) ● Our localized PO file with Japanese translations will go here: /app/Locale/jpn/LC_MESSAGES/default.po
  • 10. Creating the PO Files Manually ● Our final localized Japanese PO file will look like this. msgid "Send" msgstr " 送信 " msgid "Reply" msgstr " 返信 " ● That’s it. The translations for English and Japanese will display appropriately for the proper locale. If you want to add translations for other languages, you do the same process and put the new PO file in the directory that corresponds with that language code.
  • 11. Creating the PO Files Manually ● Our final localized Japanese PO file will look like this. msgid "Send" msgstr " 送信 " msgid "Reply" msgstr " 返信 " ● That’s it. The translations for English and Japanese will display appropriately for the proper locale. If you want to add translations for other languages, you do the same process and put the new PO file in the directory that corresponds with that language code.
  • 12. ● In your app Controller, inside before filter you need to configure the language based on the region, It will be as follows , Here am considering the japan as a language . So based on the ● Configure::write('Config.language', 'jpn');