SlideShare uma empresa Scribd logo
1 de 50
Baixar para ler offline
Translated Strings and
Foreign Language
Support in JavaScript
Web Apps
Ken Tabor
Twitter: @KenTabor
Shared
bit.ly/KenOscon13
Translating What?
Any and all blocks of text
Translating What?
Date/time formatters
Translating Where?
Single page app
Translating Myth #1
We don’t need translated text, we’re only
shipping to North America
Translating Myth #2
No need - it’s just an internal tool
Translating Myth #3
We’re a start-up ... let’s just submit
Translating OMG #1
Just before code freeze marketing asks:
Translating OMG #1
Just before code freeze marketing asks:
Hey, will you send over all the text
please? We want to do a polish pass for
voice and message before ship.
Translating OMG #1
Just before code freeze marketing asks:
Hey, will you send over all the text
please? We want to do a polish pass for
voice and message before ship.
Don’t worry we’ll return it by end of day.
Translating OMG #2
CoderSean and PM build create() feature
“Connection error, notifying the admin.”
Translating OMG #2
CoderBurin and BA build add() feature
“Network problem. Notifying the admin.”
Why Work Smarter?
Programmers: Don’t RepeatYourself
Business: Include More Customers
Marketing: Craft Consistent Message
Solution?
String Tables
Typical String Table
TS.tstring = {
appTitle: 'TString.JS',
programListing: 'Program Listing',
english: 'English',
spanish: 'Spanish',
german: 'German',
title: 'Title',
date: 'Date',
synopsis: 'Synopsis',
programDate: 'MMM Do YYYY, h:mm a'
};
Architectural Rule #1
Never hard-code text strings
Architectural Rule #2
String-tables must be easily accessed
throughout the application
Architectural Rule #3
Language string-tables must be demand-
loadable resources
Is this Difficult?
Couldn’t Google my way out of this task
JavaScript is popular lacks formal support
We’re all rushed after all
Who Am I to Do This?
I’m a front-end product engineer
Working at Sabre Holdings
Building TripCase
Our Dev Strategy
Mobile web browser (webkit)
Our Dev Strategy
iOS and Android native apps (PhoneGap)
Our Dev Strategy
Coders get smart and stay smart
Core Languages
App Structure
Presentation Layer
Utility Libs
Code Analysis/Build
Native Wrapper
JavaScript + CSS + HTML
Backbone + Underscore + RequireJS
jQuery + SASS + Compass
Handlebars + Moment + Modernizr
Jasmine + jsHint + Plato + Grunt
PhoneGap
Demo
Show the people some running code
String Table
TS.tstring = {
appTitle: 'TString.JS',
programListing: 'Program Listing',
english: 'English',
spanish: 'Spanish',
german: 'German',
title: 'Title',
date: 'Date',
synopsis: 'Synopsis',
programDate: 'MMM Do YYYY, h:mm a'
};
Global Resource
// encapsulate all code modules into a global namespace
var TS = TS || {};
TS.model = TS.model || {};
TS.view = TS.view || {};
TS.collection = TS.collection || {};
TS.app = null;
TS.tstring = null;
Template User
TS.view.Application = Backbone.View.extend({
template:
'<h1>TStringJS</h1>' +
'<h2>Example of translated strings and foreign language</h2>' +
'<select id="lang-list">' +
'<option value="english">English</option>' +
'<option value="spanish">Spanish</option>' +
'<option value="french">French</option>' +
'<option value="italian">Italian</option>' +
'</select>' +
'<button id="lang-load">Select'
Template User
TS.view.Application = Backbone.View.extend({
template:
'<h1><%= TS.tstring.appTitle %></h1>' +
'<h2><%= TS.tstring.appSubTitle %></h2>' +
'<select id="lang-list">' +
'<option value="english"><%= TS.tstring.english %></option>' +
'<option value="spanish"><%= TS.tstring.spanish %></option>' +
'<option value="french"><%= TS.tstring.french %></option>' +
'<option value="italian"><%= TS.tstring.italian %></option>' +
'</select>' +
'<button id="lang-load"><%= TS.tstring.select %>'
JavaScript User
function onSelectChoice(id) {
var userModel;
userModel = this.collection.get(id);
alert(TS.tstring.selectedProgram + ': ' +
userModel.getDisplayTitle());
}
Resource Loader
function LanguageLoad(lang) {
var langFn;
if (lang === 'english') langFn = 'en-US.js';
else if (lang === 'spanish') langFn = 'es.js';
else if (lang === 'klingon') langFn = 'tlh.js';
$.ajax({
url: 'code/strings/' + langFn,
dataType: 'script',
success: function(data, textStatus) {
TS.app.onRender();
}
});
}
Making the Case
Combine duplicating strings
Stop nearly duplicated strings
Easier word-smithing
Setup for translation services
Abstract away date/time formatting
Handlebars User
Write a “helper” function
Wraps the global resource
Param indexes into the string table
Handlebars Helper
Handlebars.registerHelper('tstring', function(key) {
var tstring = TS.tstring[key];
if (tstring === undefined)
console.log('Missing string[' + key + ']');
return tstring;
});
<h1>{{tstring “appTitle”}}</h1>
<h2>{{tstring “appSubTitle”}}</h2>
RequireJS
RequireJS has “i18n” plugin
Auto-loads based on navigator.language
At the cost of user control
Native App
All string files are packaged together
TS.tstring.en = {...};
TS.tstring.fr = {...};
TS.tstring.es = {...};
TS.tstring.tlh = {...};
TS.tstrings = TS.tstring.es;
Testing
Test entire app in English
Native speaker confirms translations
Wait on bug reports
Testing
Automated testing: Jasmine and Selenium
Manual debug: English with “SP-” prefix
The “Ken Bug”
Don’t accidentally ship your debug files
Think About It
Start from the start
Retrofitting costed a 50hr week
Plus 20hr regression testing
Think About It
Server-side error conditions happen
Map return codes rather than text
Keep Thinking
Pluralization functions
Keep Thinking
Coordinate with plugins & libraries
Keep Thinking
Designers must brain-sweat composition
Questions?
Thank-You
bit.ly/KenOscon13
Ken Tabor (@KenTabor)

Mais conteúdo relacionado

Destaque

My trans kit checklist gw1 ds1_gw3
My trans kit checklist gw1 ds1_gw3My trans kit checklist gw1 ds1_gw3
My trans kit checklist gw1 ds1_gw3
David Sommer
 
Conspiracy Profile
Conspiracy ProfileConspiracy Profile
Conspiracy Profile
charlyheus
 
แรงดันในของเหลว
แรงดันในของเหลวแรงดันในของเหลว
แรงดันในของเหลว
tewin2553
 
Neue aufregende Web Technologien, HTML5 + CSS3 anhand von Praxisbeispielen le...
Neue aufregende Web Technologien, HTML5 + CSS3 anhand von Praxisbeispielen le...Neue aufregende Web Technologien, HTML5 + CSS3 anhand von Praxisbeispielen le...
Neue aufregende Web Technologien, HTML5 + CSS3 anhand von Praxisbeispielen le...
Eric Eggert
 
Stc 2014 unraveling the mysteries of localization kits
Stc 2014 unraveling the mysteries of localization kitsStc 2014 unraveling the mysteries of localization kits
Stc 2014 unraveling the mysteries of localization kits
David Sommer
 
UTF-8: The Secret of Character Encoding
UTF-8: The Secret of Character EncodingUTF-8: The Secret of Character Encoding
UTF-8: The Secret of Character Encoding
Bert Pattyn
 

Destaque (20)

My trans kit checklist gw1 ds1_gw3
My trans kit checklist gw1 ds1_gw3My trans kit checklist gw1 ds1_gw3
My trans kit checklist gw1 ds1_gw3
 
Glossary
GlossaryGlossary
Glossary
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
 
Natural language processing
Natural language processingNatural language processing
Natural language processing
 
The ruby on rails i18n core api-Neeraj Kumar
The ruby on rails i18n core api-Neeraj KumarThe ruby on rails i18n core api-Neeraj Kumar
The ruby on rails i18n core api-Neeraj Kumar
 
Strategies for Friendly English and Successful Localization
Strategies for Friendly English and Successful LocalizationStrategies for Friendly English and Successful Localization
Strategies for Friendly English and Successful Localization
 
Designing for Multiple Mobile Platforms
Designing for Multiple Mobile PlatformsDesigning for Multiple Mobile Platforms
Designing for Multiple Mobile Platforms
 
Conspiracy Profile
Conspiracy ProfileConspiracy Profile
Conspiracy Profile
 
Putting Out Fires with Content Strategy (STC Academic SIG)
Putting Out Fires with Content Strategy (STC Academic SIG)Putting Out Fires with Content Strategy (STC Academic SIG)
Putting Out Fires with Content Strategy (STC Academic SIG)
 
Verb to be
Verb to beVerb to be
Verb to be
 
Automatic Language Identification
Automatic Language IdentificationAutomatic Language Identification
Automatic Language Identification
 
Silmeyiniz
SilmeyinizSilmeyiniz
Silmeyiniz
 
Building Quality Experiences for Users in Any Language
Building Quality Experiences for Users in Any LanguageBuilding Quality Experiences for Users in Any Language
Building Quality Experiences for Users in Any Language
 
Trabajo grupal
Trabajo grupalTrabajo grupal
Trabajo grupal
 
Django & Drupal: A Tale of Two Cities
Django & Drupal: A Tale of Two CitiesDjango & Drupal: A Tale of Two Cities
Django & Drupal: A Tale of Two Cities
 
Open Software Platforms for Mobile Digital Broadcasting
Open Software Platforms for Mobile Digital BroadcastingOpen Software Platforms for Mobile Digital Broadcasting
Open Software Platforms for Mobile Digital Broadcasting
 
แรงดันในของเหลว
แรงดันในของเหลวแรงดันในของเหลว
แรงดันในของเหลว
 
Neue aufregende Web Technologien, HTML5 + CSS3 anhand von Praxisbeispielen le...
Neue aufregende Web Technologien, HTML5 + CSS3 anhand von Praxisbeispielen le...Neue aufregende Web Technologien, HTML5 + CSS3 anhand von Praxisbeispielen le...
Neue aufregende Web Technologien, HTML5 + CSS3 anhand von Praxisbeispielen le...
 
Stc 2014 unraveling the mysteries of localization kits
Stc 2014 unraveling the mysteries of localization kitsStc 2014 unraveling the mysteries of localization kits
Stc 2014 unraveling the mysteries of localization kits
 
UTF-8: The Secret of Character Encoding
UTF-8: The Secret of Character EncodingUTF-8: The Secret of Character Encoding
UTF-8: The Secret of Character Encoding
 

Semelhante a Translated Strings and Foreign Language Support in JavaScript Web Apps - OSCON 2013

I18n
I18nI18n
I18n
soon
 
Jscript Fundamentals
Jscript FundamentalsJscript Fundamentals
Jscript Fundamentals
rspaike
 
Dart, Darrt, Darrrt
Dart, Darrt, DarrrtDart, Darrt, Darrrt
Dart, Darrt, Darrrt
Jana Moudrá
 
Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...
Matteo Collina
 

Semelhante a Translated Strings and Foreign Language Support in JavaScript Web Apps - OSCON 2013 (20)

Huge web apps web expo 2013
Huge web apps web expo 2013Huge web apps web expo 2013
Huge web apps web expo 2013
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom Manipulation
 
I18n
I18nI18n
I18n
 
Jscript Fundamentals
Jscript FundamentalsJscript Fundamentals
Jscript Fundamentals
 
Dart, Darrt, Darrrt
Dart, Darrt, DarrrtDart, Darrt, Darrrt
Dart, Darrt, Darrrt
 
Can your App parle Francais?
Can your App parle Francais?Can your App parle Francais?
Can your App parle Francais?
 
FAESA CONENCO 2013: Sencha Touch 2 + PhoneGap
FAESA CONENCO 2013: Sencha Touch 2 + PhoneGapFAESA CONENCO 2013: Sencha Touch 2 + PhoneGap
FAESA CONENCO 2013: Sencha Touch 2 + PhoneGap
 
Introduction of javascript
Introduction of javascriptIntroduction of javascript
Introduction of javascript
 
From Ruby to Node.js
From Ruby to Node.jsFrom Ruby to Node.js
From Ruby to Node.js
 
IBM Lotus Notes Domino XPages and XPages for Mobile
IBM Lotus Notes Domino XPages and XPages for MobileIBM Lotus Notes Domino XPages and XPages for Mobile
IBM Lotus Notes Domino XPages and XPages for Mobile
 
Html javascript
Html javascriptHtml javascript
Html javascript
 
JS class slides (2016)
JS class slides (2016)JS class slides (2016)
JS class slides (2016)
 
Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...
 
Intro to Android Programming
Intro to Android ProgrammingIntro to Android Programming
Intro to Android Programming
 
JS Class 2016
JS Class 2016JS Class 2016
JS Class 2016
 
Domain Specific Languages
Domain Specific LanguagesDomain Specific Languages
Domain Specific Languages
 
Client-side JavaScript Vulnerabilities
Client-side JavaScript VulnerabilitiesClient-side JavaScript Vulnerabilities
Client-side JavaScript Vulnerabilities
 
JavaScript 2.0 in Dreamweaver CS4
JavaScript 2.0 in Dreamweaver CS4JavaScript 2.0 in Dreamweaver CS4
JavaScript 2.0 in Dreamweaver CS4
 
An Introduction to TypeScript
An Introduction to TypeScriptAn Introduction to TypeScript
An Introduction to TypeScript
 
jQuery Presentation - Refresh Events
jQuery Presentation - Refresh EventsjQuery Presentation - Refresh Events
jQuery Presentation - Refresh Events
 

Mais de Ken Tabor

Mais de Ken Tabor (16)

Introduction to Coding a Webpage
Introduction to Coding a WebpageIntroduction to Coding a Webpage
Introduction to Coding a Webpage
 
Making the Difficult, Simple(r)
Making the Difficult, Simple(r)Making the Difficult, Simple(r)
Making the Difficult, Simple(r)
 
On Writing: What Best Selling Author David Baldacci Taught Me About Writing a...
On Writing: What Best Selling Author David Baldacci Taught Me About Writing a...On Writing: What Best Selling Author David Baldacci Taught Me About Writing a...
On Writing: What Best Selling Author David Baldacci Taught Me About Writing a...
 
Demo Hard: Things Nobody Told an Introvert About Public Speaking
Demo Hard: Things Nobody Told an Introvert About Public SpeakingDemo Hard: Things Nobody Told an Introvert About Public Speaking
Demo Hard: Things Nobody Told an Introvert About Public Speaking
 
Machine Learning: Understanding the Invisible Force Changing Our World
Machine Learning: Understanding the Invisible Force Changing Our WorldMachine Learning: Understanding the Invisible Force Changing Our World
Machine Learning: Understanding the Invisible Force Changing Our World
 
10 Things About Human UI that Will Change Forever in Self-Driving Cars
10 Things About Human UI that Will Change Forever in Self-Driving Cars10 Things About Human UI that Will Change Forever in Self-Driving Cars
10 Things About Human UI that Will Change Forever in Self-Driving Cars
 
Ten Easy Ways to Improve Your Conference Talk
Ten Easy Ways to Improve Your Conference TalkTen Easy Ways to Improve Your Conference Talk
Ten Easy Ways to Improve Your Conference Talk
 
Measuring the Mobile Experience at SXSW 2016
Measuring the Mobile Experience at SXSW 2016Measuring the Mobile Experience at SXSW 2016
Measuring the Mobile Experience at SXSW 2016
 
Measuring the Mobile Experience: The Analytics of Handheld UX
Measuring the Mobile Experience: The Analytics of Handheld UXMeasuring the Mobile Experience: The Analytics of Handheld UX
Measuring the Mobile Experience: The Analytics of Handheld UX
 
Your Future HTML: The Evolution of Site Design with Web Components
Your Future HTML: The Evolution of Site Design with Web ComponentsYour Future HTML: The Evolution of Site Design with Web Components
Your Future HTML: The Evolution of Site Design with Web Components
 
10 Tips for a Winning Hackathon Pitch
10 Tips for a Winning Hackathon Pitch10 Tips for a Winning Hackathon Pitch
10 Tips for a Winning Hackathon Pitch
 
10 Leadership Lessons from the Tao Te Ching
10 Leadership Lessons from the Tao Te Ching10 Leadership Lessons from the Tao Te Ching
10 Leadership Lessons from the Tao Te Ching
 
BigDesign 2014 - What's Before Mobile First?
BigDesign 2014 - What's Before Mobile First?BigDesign 2014 - What's Before Mobile First?
BigDesign 2014 - What's Before Mobile First?
 
UXPA Dallas - Google Analytics and What's Before Mobile First
UXPA Dallas - Google Analytics and What's Before Mobile FirstUXPA Dallas - Google Analytics and What's Before Mobile First
UXPA Dallas - Google Analytics and What's Before Mobile First
 
WVPDX 2014 - Hammering Responsive Web Design Into Shape
WVPDX 2014 - Hammering Responsive Web Design Into ShapeWVPDX 2014 - Hammering Responsive Web Design Into Shape
WVPDX 2014 - Hammering Responsive Web Design Into Shape
 
Hammering Responsive Web Design Into Shape
Hammering Responsive Web Design Into ShapeHammering Responsive Web Design Into Shape
Hammering Responsive Web Design Into Shape
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Translated Strings and Foreign Language Support in JavaScript Web Apps - OSCON 2013