Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 34 lines (26 sloc) 0.733 kB
a373e66 sorting the yaml of the yaml strings for nicer edition, defaulting bl…
Emmanuel Oga authored
1 require 'ext_helpers'
fcdba63 Fixed some Rack and Sinatra deprecations. Added require for yaml.
Norman Clarke authored
2 require 'yaml'
a373e66 sorting the yaml of the yaml strings for nicer edition, defaulting bl…
Emmanuel Oga authored
3
4936fe5 Added very basic localization framework.
Norman Clarke authored
4 module L18n
5
ced66df Cleaned up indentation and whitespace.
Norman Clarke authored
6 # The default is currently "en." Once the spanish translation is complete,
7 # we should probably change this to "es."
a373e66 sorting the yaml of the yaml strings for nicer edition, defaulting bl…
Emmanuel Oga authored
8 def default_lang
9056bb0 Tweaked Spanish YAML format.
Norman Clarke authored
9 'es'
a373e66 sorting the yaml of the yaml strings for nicer edition, defaulting bl…
Emmanuel Oga authored
10 end
11
4936fe5 Added very basic localization framework.
Norman Clarke authored
12 def lang
a373e66 sorting the yaml of the yaml strings for nicer edition, defaulting bl…
Emmanuel Oga authored
13 @lang = params["lang"] || request.cookies["lang"] || default_lang
fcdba63 Fixed some Rack and Sinatra deprecations. Added require for yaml.
Norman Clarke authored
14 response.set_cookie("lang", @lang)
4936fe5 Added very basic localization framework.
Norman Clarke authored
15 @lang
16 end
17
a373e66 sorting the yaml of the yaml strings for nicer edition, defaulting bl…
Emmanuel Oga authored
18
19 def get_string(key, l = lang)
20 k = key.to_s
21 str = strings[l][k]
22 str = strings[default_lang][k] if str.blank? && default_lang != l
23 str.blank? ? k : str
4936fe5 Added very basic localization framework.
Norman Clarke authored
24 end
25
26 def strings
27 @strings ||= {
28 "en" => YAML.load(File.read(File.dirname(__FILE__) + "/strings.en.yaml")),
29 "es" => YAML.load(File.read(File.dirname(__FILE__) + "/strings.es.yaml"))
30 }
31 end
32
a373e66 sorting the yaml of the yaml strings for nicer edition, defaulting bl…
Emmanuel Oga authored
33 end
Something went wrong with that request. Please try again.