Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract all strings, use gettext-like strategy for l10n #22

Closed
zepheiryan opened this issue Sep 24, 2011 · 4 comments
Closed

Extract all strings, use gettext-like strategy for l10n #22

zepheiryan opened this issue Sep 24, 2011 · 4 comments

Comments

@zepheiryan
Copy link
Member

Extract all of the strings sitting around in various code files. Replace with a gettext-like strategy (any libraries?) so English strings can be keys for their localized translations and stand in as the default value.

@zepheiryan
Copy link
Member Author

There are a number of matters to address in pursuing this.

  1. Add a parameter-based method of setting the page's preferred locale. The methods surrounding locale deal solely with ways to force one locale at all times or to let the client decide; the page that's actually serving the Exhibit should have an opportunity to weigh in.
  2. Add getters and setters for finding out what the server, Exhibit default, and user agent preferred locales are and which one is actually in operation.
  3. Once the locale to use is determined, load the Exhibit default and increasingly specific locales depending on the client. E.g., if the user-agent is using pt-BR, load default, pt, and pt-BR (given they all exist). Lookup in decreasing specificity / preference: pt-BR, pt, and finally the default, which will be en.
  4. Restructure so l10n lookup is a key-based hash table instead of the objects with some constants and some methods strategy now in play.
  5. Rewrite locales to reside in one JSON file. Eliminate the need to structure and load the locales as modules, loading just the JSON file. Likely eliminate the need to bundle them. Rewrite methods as sprintf statements where appropriate, move complex methods into util/ miscellaneous files when needed.
  6. Note to localization authors that a missing key will allow for gracefully degrading, but an empty string will get used as-is.

@zepheiryan
Copy link
Member Author

For developers, call with Exhibit._(key, arg1, arg2, ...); for example, Exhibit._("%general.badJsonMessage", url, errorType)

@zepheiryan
Copy link
Member Author

There are a couple non-string entries in the localization hashes that I've left alone to ease this transition; they may need to be modified or excised at a later time. Some entries are booleans, arrays, or HTML templates - the HTML is somewhat understandable; in an RTL language, the tags should be rearranged. It is a bit off to have it in there, but it will stay for now.

zepheiryan added a commit that referenced this issue Jan 25, 2012
…usage of old style of localization to new and starting to move all localizable content out of scripts. for #22. also addresses some minor consistency issues in formatting HTML output, and some new methods to compensate for methods that used to sit in localizations.
@zepheiryan
Copy link
Member Author

While this feature is implemented, there is another somewhat bland task to be done of translating all of the existing locales into the new system. There's a record of progress in the wiki, under the comparison to earlier versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant