M ULTI - LANGUAGE FOR PHP WITH G ETTEXT Binh Quan 2014-05-20.

Slides:



Advertisements
Similar presentations
PHP Form and File Handling
Advertisements

Working with Forms. how are forms manipulated? the document object contains an array of forms objects, one for each form, in document order –forms[] any.
PHP Hypertext Preprocessor Information Systems 337 Prof. Harry Plantinga.
Introduction to JavaScript
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
Why python? Automate processes Batch programming Faster Open source Easy recognition of errors Good for data management What is python? Scripting programming.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
Kyung Hee University 1 1 Application Layer. 2 Kyung Hee University Position of Application Layer.
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
Multiple Tiers in Action
DT228/3 Web Development JSP: Directives and Scripting elements.
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development I” Course materials.
CS Learning Centre PHP Tutorial. Introduction ⇨ Based on PHP and MySQL Web Development, Third Edition (Available as CS eBook from Dal Library) ⇨ Other.
Overview of JSP Technology. The need of JSP With servlets, it is easy to – Read form data – Read HTTP request headers – Set HTTP status codes and response.
ITM352 PHP and Dynamic Web Pages: Server Side Processing.
Javascript and the Web Whys and Hows of Javascript.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Advanced Web 2012 Lecture 4 Sean Costain PHP Sean Costain 2012 What is PHP? PHP is a widely-used general-purpose scripting language that is especially.
INFM 603: Information Technology and Organizational Context Jimmy Lin The iSchool University of Maryland Thursday, October 18, 2012 Session 7: PHP.
AJAX Chat Analysis and Design Rui Zhao CS SPG UCCS.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
Prevent Cross-Site Scripting (XSS) attack
Homework for October 2011 Nikolay Kostov Telerik Corporation
CSE3310: Web training A JumpStart for Project.
Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,
INTERNET APPLICATION DEVELOPMENT For More visit:
Architecture of the web Client Server retrieved or generated web page.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
COOKIES and SESSIONS. COOKIES A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each.
JavaScript Syntax, how to use it in a HTML document
XP Tutorial 8 Adding Interactivity with ActionScript.
D. Heynderickx DH Consultancy, Leuven, Belgium 22 April 2010EuroPlanet, London, UK.
TOPIC II Dynamic HTML Prepared by: Nimcan Cabd Cali.
CITA 310 Section 7 Installing and Testing a Programming Environment (Textbook Chapter 7)
HTML JAVASCRIPT. CONTENTS Javascript Example NOSCRIPT Tag Advantages Summary Exercise.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
HTML Overview Part 5 – JavaScript 1. Scripts 2  Scripts are used to add dynamic content to a web page.  Scripts consist of a list of commands that execute.
Dawn Pedersen. What is JavaScript? JavaScript is the basis for both jQuery and Spry applications JavaScript is referred to as a client-side scripting.
CSC 2720 Building Web Applications Basic Frameworks for Building Dynamic Web Sites / Web Applications.
 A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests.
Javascript Overview. What is Javascript? May be one of the most popular programming languages ever Runs in the browser, not on the server All modern browsers.
 A PHP script can be placed anywhere in the document.  A PHP script starts with  The default file extension for PHP files is ".php".  A PHP file normally.
 Before you continue you should have a basic understanding of the following:  HTML  CSS  JavaScript.
Project 5: Customizing User Content Essentials for Design JavaScript Level Two Michael Brooks.
Learning Aim C.  In this section we will look at some simple client-side scripts, browser compatibility, exporting and compressing and suitable file.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
CSE3310: Web training A JumpStart for Project. Outline Introduction to Website development Web Development Languages How to build simple Pages in PHP.
JavaScript: A short introduction Joseph Lee Created by Joseph Lee.
Web development. What is web development? - It is a broad term for the work involved in developing a web site for the Internet - It can range from developing.
Module 1 Introduction to JavaScript
Egyptian Language School General Questions Prep.2
Introduction to Dynamic Web Programming
ITM352 PHP and Dynamic Web Pages: Server Side Processing 1.
WWW and HTTP King Fahd University of Petroleum & Minerals
PHP Training at GoLogica in Bangalore
PHP / MySQL Introduction
PHP Introduction.
Chapter 27 WWW and HTTP.
Optical Character Recognition
PHP.
Unit 6 part 3 Test Javascript Test.
Intro to PHP.
Tutorial 6 PHP & MySQL Li Xu
Tutorial 10: Programming with javascript
Architecture of the web
Introduction to JavaScript
Presentation transcript:

M ULTI - LANGUAGE FOR PHP WITH G ETTEXT Binh Quan

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 5

4. Multi-language for images & static pages With images ”/> With static pages 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

Q UESTION ? 12