How to localize ordinal numbers
Ordinal numbers are sometimes found in many websites and mobile apps, and the localization of them varies from language to language. To solve this problem, there are a number of external libraries that you can use to convert and localize ordinal number formats used in other languages.
External libraries for localizing ordinal numbers
Here are a few examples of external libraries you can use:
- Moment.js
- Useful for ordinal numbers inside of dates.
- Numeral.js
- Angular Localization and Internationalization
- You can use this library if you are using Angular to create your site/app.
- Use the built in i18n features of JavaScript: the Intl object
- Check out this article to get started: How to get started with internationalization in JavaScript
- Globalize.js
Tell Localize about your converted ordinal numbers
After you've implemented the localization of ordinal numbers in your website or app, the next step is to tell Localize whether to ignore those ordinal numbers that it finds in your content (if you've already provided the complete translations).
Here are a few methods that you can use, depending on your situation:
- Define variables in your phrases
- Add
<var>
tags to your HTML - Use the Block CSS Classes and IDs feature
- Add a
notranslate
attribute - Add an
ignore
attribute
Updated about 3 years ago