Ticket #2774 (closed enhancement: fixed)

Opened 21 months ago

Last modified 21 months ago

Provide a method of passing localised strings into the JavaScript

Reported by: aron.carroll Owned by: toby
Priority: critical Milestone: demo phase 3
Component: ckan Keywords:
Cc: Repository: ckan
Theme: none

Description

We need to be able to do the following:

  • Rip the localised strings from the JavaScript? source code. These are strings that look like _('String'), translate('String') and isPlural('String') .
  • An endpoint that provides the translations in the correct locale for the user.
  • The endpoint should provide the locale as JSON (possibly using http://jsgettext.berlios.de/doc/html/po2json.html or similar tool)

The JavaScript? can then read this file on page load.

Change History

comment:1 Changed 21 months ago by toby

@aron

I've created some js translations note that they are untranslated except for zh_TW which is mangled. At the moment they are just a json blob in public/base/i18n/<locale>.js

What more do you need? It seems to me that you just need either

some_var = {json} or some_function({json})

let me know your preference or do we want this purely as an ajax call? If it's ajax I think we want a common approach like in http://trac.ckan.org/ticket/2698 which I prefer to a unhelpful response

comment:2 Changed 21 months ago by aron.carroll

I'm happy to just make ajax requests to public/base/i18n/<locale>.js, however this will use the language set in the <html lang> attribute. So if this file doesn't exist then we'll get a 404 and show the english.

If we want something more sophisticated, determine an appropriate fallback etc, then I think the API is the way to go. Or we could get CKAN to determine the appropriate language file and include it in the page source...

comment:3 Changed 21 months ago by toby

for now shall we just include it in the page?

let me know how you want it included eg

var = {}, fn({}), $(fn({})) etc

comment:4 Changed 21 months ago by aron.carroll

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.