Skip to content

ghidinelli/g11n.cfc

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

g11n.cfc

A ColdFusion Component that helps with Globalization (g11n) - Internationalization (i18n) and Localization (l10n)

For a primer on Globalization with ColdFusion, check [https://gist.github.com/coldfusionPaul/3779416 this gist] from Paul Hastings (who knows a ton about g11n).

Some assumptions:

  • Your content is in utf-8 and stored in the database as unicode
  • You have <cfprocessingdirective pageencoding="UTF-8"/> everywhere
  • You realize the built-in locale name and LS* functions are inadequate

Using g11n.cfc is easy:

g11n = createObject("component", "g11n").init(locale = "en_US", tzid = "US/Pacific");
writeOutput(g11n.getDateMask("short")); // M/d/yy h:mm a
writeOutput(g11n.formatDateTime(now(), "short")); // now() formatted as 'M/d/yy h:mm a' in Pacific time
writeOutput(g11n.formatCurrency(50000.50)); // $50,000.50

You can also pass the desired locale and timezone to most methods or change the default:

writeOutput(g11n.getDateMask(locale = "en_GB", mask = "short")); // dd/MM/yy HH:mm
g11n.setDefaultLocale("en_GB");
writeOutput(g11n.formatCurrency(50000.50)); // £50.000,50

About

A ColdFusion Component that helps with Globalization (g11n) - Internationalization (i18n) and Localization (l10n)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published