Skip to content

Enable programmatic locale switching #173

Open
@lorcan

Description

@lorcan

I'd like to be able to switch locales dynamically at client-side if possible. Would it be possible to store the locale settings in hashes, like this (adapted from the fr locale):

// French
jQuery.timeago.settings.strings['fr'] = {
   // environ ~= about, it's optional
   prefixAgo: "il y a",
   prefixFromNow: "d'ici",
   seconds: "moins d'une minute",
   minute: "environ une minute",
   minutes: "environ %d minutes",
   hour: "environ une heure",
   hours: "environ %d heures",
   day: "environ un jour",
   days: "environ %d jours",
   month: "environ un mois",
   months: "environ %d mois",
   year: "un an",
   years: "%d ans"
};

This would enable multiple locales to be pulled in at once and selected by using jQuery.timeago.settings.strings = jQuery.timeago.settings.strings['fr']; rather than by overriding jQuery.timeago.settings.strings by pulling in an additional locale file (which either necessitates an additional HTTP request or some server side locale switching).

I'm happy to put together a PR with tests if there is any demand for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions