Comparing JavaScript Libraries - Jsi18n

Transcription

www.XenCraft.comComparing JavaScript LibrariesCraig Cummings, Tex TexinOctober 27, 2015

AbstractWhich JavaScript library is best forinternational deployment? This sessionpresents the results of several years ofinvestigation of features of JavaScriptlibraries and their suitability forinternational markets. We will show howthe libraries were evaluated andcompare the results for ECMA, Dojo,jQuery Globalize, Closure, iLib, ibm-js andintl.js. The results may surprise you andwill be useful to anyone designing newinternational or multilingual JavaScriptapplications or supporting existing ones.2

Agenda Background Evaluation Criteria Libraries Results Q&A3

Origins Project to extend globalization- Complex e-Commerce Software- Multiple subsystems- Different development teams- Different libraries already in use Should we standardize? Which one?- Reduce maintenance- Increase competence4

Evaluation Criteria Support for target and future markets Number of internationalization features Quality of internationalization features Maintained? Widely used? Ease of migration from existing libraries Browser compatibility5

Internationalization FeatureRequirements Encoding Support- Unicode- Supplementary Chars- Bidi algorithm, shaping- Character Properties- Charset detection- Conversion- IDN/IRI- Normalization- Collation Text Support- Case, Accent Mapping- Boundary detection- Transliteration Message Formatting- Resource/propertiesfiles- Plurals, Gender, et al6

Internationalization FeatureRequirements (more) Data formats- Date, time, calendar- Time zone- Number, Currency- Postal Address- Names, Honorifics- Phone numbers Regular Expressions Compression Locales- Names (BCP 47)- Negotiation- Fallback- Detection Measurementsystems7

Candidate LibrariesAccDCAmple SDKCupQDHTMLXDojoEcho3EnyoExt JSGoogle Web rototypePyjamasqooxdooRialto ToolkitRicoSmartClient & SmartGWTWakandaWeb AtomsWebixYUIZK8

I18n Libraries(general libraries left; messages-specific right)ECMA (402 262)DojojQuery jsdate.jsjQuery.nowjQuery.i18n (Wikimedia)L20n eformat.jsl10n.jsl10nsbrowser-i18nrequirejs-i18n9

The ECMA I18n Standard Why not rely on the new standard?- ECMA-402 1st Edition released Dec, 2012 2nd Edition released Jun, 2015- ECMA-262 (supplementary character support) 6th Edition released Jun 2015- More details at site of one of authors ternationalization/index.html10

Desirable Features- Cross-browser compatibility – including Safari Desktop, Mobile, Node.js, Older versions- Based on CLDR Locale Data- Based on ICU (see next slide)- Ease of data update and customization Time zone data (Olson/IANA) CLDR locale corrections and additions- Part of a larger (useful) JS platform- Well-performing (CPU, download size, disk, memory)11

ICU Value (Skeleton Dates)DateFormat(DateFormat.FULL) SimpleDateFormatICU Skeleton JS ResultsEnglishWednesday, December 23, 2015Wednesday December 23 2015Wednesday, December 23, 2015Frenchmercredi 23 décembre 2015mercredi décembre 23 2015mercredi 23 décembre 2015GermanMittwoch, 23. Dezember 2015Mittwoch Dezember 23 2015Mittwoch, 23. Dezember 2015SpanishBrazilianPortuguesemiércoles 23 de diciembre de 2015miércoles diciembre 23 2015miércoles, 23 de diciembre de 2015Japanese2015年12月23日水曜日 12月 23 ese2015년 12월 23일 수요일수요일 12월 23 20152015년 12월 23일 수요일2015年12月23日 星期三星期三 十二月 23 20152015年12月23日星期三Quarta-feira, 23 de Dezembro de 2015 quarta-feira dezembro 23 2015 quarta-feira, 23 de dezembro de 201512

Scoping Need to limit investigation Writing tests and reviewing each featurefor each library would take a large effort Reduced list of libraries (sort of; see next bullet)- Already in use or strongly recommended- ECMA, Dojo, jQuery Globalize, iLib, Closure, ibmjs, intl.js (honorable mention to moment.js & numeral.js) Plus a plethora of message formatting libs13

Minimal Feature Requirements(Ideally in one library) Encodings- Detection, Supplementary characters, Conversion Locales: European and Asian Markets Data Formats- Dates, times, numbers, currency- Localized Gregorian calendar Message formatting, Externalized text IDN, IRI14

Updated Goals Adequate i18n for foreseeable future Meets minimal i18n requirements Meets browser requirements Acceptable to development teams Part of a larger library Easy to update data Easy to migrate to15

Example Challenge: Dates 142 different date formats in use 300 different date formats in use Unclear history or requirements for each format Unclear how to internationalize some formats Unclear whether to internationalize some formats- A little clearer as some of these derive fromdifferent databases, programming languages, andstandards.- Still a mess!16

js-i18n.comhttp://js-i18n.com17

Passing Unit TestsLibDFODFO AllDTFDTF AllNFNF 9168167239676Intl.js1192179232148839671DojoDFO Date format onlyDTF Date and time formatNF Number format18

Measure by Caveats iLib- Comes out-of-the-box with only 20 locales Instructions about building more are hard to find Dojo and ibm-js- 600 additional locales can be built with relative ease. Tools andinstructions available per readme files in package.- ibm-js readme lacks links to 2/3 require-related libraries JQ on server/browser (not node.js) is painful. Even thenneeds tweaking to remove locales from jQuery require19

Rafael Xavier Comparison ript-globalization)20

Feature Comparison Eye /ECMA683682683683683CLDR Locale Data Date/Time Number/Currency/Percentage International Calendars Parsing partial Collation LocaleBidi †iLib additionally has support for time zone, measurement, name, address and phone formats as well asresource files, Unicode normalization, case mapping, encoding conversion and more†† ECMA (and ibm-js & intl.js) has (have) extensive locale detection, negotiation, and fallback support††† Notably still missing is support for boundary detection/wrapping, Unicode regex, and IDNs/IRIs21

Message Library ComparisonLibConcatGenderPluralOrdinalFormatJS JQ I18n L20N CldrPlural JQ Globalize Closure messageformat.js i18next l10ns browser-i18n iLib ECMA22 GrammarCustom

Conclusion Further investigation and recent changes indicatebetter i18n coverage in “basic” areas (a problem notedin the past)- Improvements on mobile ECMA could use more consistent results acrossbrowsers Extensive evaluation is nice to have; scoping to near-term needs is practical- Risks repeating and replacing library in the future23

Resources ECMA- ECMA-402 Edition 2 A-402.pdf- ECMA-262 Edition 6 (supplementary characters) es/ECMA-ST/Ecma-262.pdf- Mozilla Developer Network cript/Reference/Global Objects/Intl24

Resources (other libraries)DojojQuery cma402https://github.com/andyearnshaw/Intl.js/25

Questions?26

Craig R. CummingsPrincipal Software Engineer – I18n, InformaticaCraig has been working in the field of softwareglobalization for over twenty years. Before his roleat Informatica, Craig was at Zynga making games ina variety of languages including Arabic. Beforethat, at Yahoo! Inc., he helped drive corporatetechnical strategy for internationalization with aparticular focus on Middle Eastern markets. Priorto that, Craig was with Oracle's Applicationsglobalization team where he worked closely withSun's internationalization team to shape some ofthe pluggable locale, resource bundle, font, andsupplementary character support in Java.27

Tex TexinGlobalization Architect, XenCraftTex Texin is an industry thought leader specializing in business and softwareglobalization services. His expertise includes global product strategy, Unicode andinternationalization architecture, and cost-effective implementation and testing. Overthe past two decades, Tex has created numerous global products, ledinternationalization development teams, and guided companies in taking business tonew regional markets.Tex is a contributor to several internationalization standards for software and on theWeb. He is on the steering committees of open source products and the programcommittees for Unicode and other conferences.Tex is a popular speaker at conferences around the world and provides on-site trainingon Unicode, internationalization, and globalization worldwide.Tex maintains two Web sites for internationalization, the popular, instructionalwww.I18nGuy.com site and the site for his business www.XenCraft.com.Tex is founder and Chief Globalization Architect for XenCraft. XenCraft provides globalbusiness consulting and software design, implementation, test and training serviceson globalization product strategy and software internationalization architecture.28

Principal Software Engineer - I18n, Informatica Craig has been working in the field of software globalization for over twenty years. Before his role at Informatica, Craig was at Zynga making games in a variety of languages including Arabic. Before that, at Yahoo! Inc., he helped drive corporate technical strategy for internationalization with a