Tell Potlatch 2 which locale to use
authorTom Hughes <tom@compton.nu>
Wed, 6 Apr 2011 20:22:47 +0000 (21:22 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 6 Apr 2011 20:22:47 +0000 (21:22 +0100)
app/views/site/_potlatch2.html.erb
lib/potlatch2.rb [new file with mode: 0644]

index 760927a82d6cdd3ee2d316a153e825917018e178..240bceaccdf1ca5286cffb37c285ffd8375db267 100644 (file)
@@ -10,6 +10,8 @@
 <script type="text/javascript">alert("<%= t 'site.edit.potlatch2_not_configured' %>")</script>
 <% end %>
 
+<% locale = request.compatible_language_from(Potlatch2::LOCALES.keys) %>
+
 <script type="text/javascript" defer="defer">
   var brokenContentSize = $("content").offsetWidth == 0;
   var fo = new SWFObject("<%= asset_path("/potlatch2/potlatch2.swf") %>", "potlatch", "100%", "100%", "9", "#FFFFFF");
@@ -28,6 +30,7 @@
     fo.addParam("base","/potlatch2");
     if (lat) { fo.addVariable("lat",lat); }
     if (lon) { fo.addVariable("lon",lon); }
+    fo.addVariable("locale", "<%= Potlatch2::LOCALES[locale] %>");
     <% if params['gpx'] %>
     fo.addVariable('gpx' ,'<%= h(params['gpx']) %>');
     <% end %>
diff --git a/lib/potlatch2.rb b/lib/potlatch2.rb
new file mode 100644 (file)
index 0000000..4b64d66
--- /dev/null
@@ -0,0 +1,13 @@
+module Potlatch2
+  LOCALES = {
+    "de" => "de_DE",
+    "de-DE" => "de_DE",
+    "en" => "en_US",
+    "en-GB" => "en_GB",
+    "en-US" => "en_US",
+    "fr" => "fr_FR",
+    "fr-FR" => "fr_FR",
+    "pl" => "pl_PL",
+    "pl-PL" => "pl_PL"
+  }
+end