aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2011-01-12 15:22:15 +0000
committerSeb Bacon <seb.bacon@gmail.com>2011-03-10 09:55:22 +0000
commit9b746bd34b2b6d0ba71fd740a83f4c6d2da123f0 (patch)
tree94e63af60b43acd9c8caec2d79097bd527b1186c
parent11fa9d4178fe26f4c14acaf1816361bf8e5e7c9e (diff)
initial, basic i18n support with gettext
-rw-r--r--app/controllers/application_controller.rb2
-rw-r--r--app/views/general/frontpage.rhtml6
-rw-r--r--config/environment.rb16
-rw-r--r--config/environments/development.rb2
-rw-r--r--config/initializers/fast_gettext.rb6
-rw-r--r--lib/tasks/gettext.rake5
-rw-r--r--locale/app.pot3
-rw-r--r--locale/es/app.po381
-rw-r--r--script/generate_pot.sh9
9 files changed, 411 insertions, 19 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 9382e077f..61a2444e3 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -12,7 +12,7 @@
class ApplicationController < ActionController::Base
# Standard headers, footers and navigation for whole site
layout "default"
- # set locale
+ include FastGettext::Translation # make functions like _, n_, N_ etc available)
before_filter :set_gettext_locale
# scrub sensitive parameters from the logs
filter_parameter_logging :password
diff --git a/app/views/general/frontpage.rhtml b/app/views/general/frontpage.rhtml
index 51bf55e34..e5f9a14f8 100644
--- a/app/views/general/frontpage.rhtml
+++ b/app/views/general/frontpage.rhtml
@@ -1,13 +1,13 @@
<% view_cache :ttl => 5.minutes do %>
<div id="frontpage_search">
- <h1>Make or explore Freedom of Information requests</h1>
+ <h1><%= _('Make or explore Freedom of Information requests') %></h1>
<% form_tag({:action => "search_redirect"}, {:id => "search_form"}) do %>
<p>
- First, type in the <strong>name of the UK public authority</strong> you'd
+ <%= _('First, type in the <strong>name of the UK public authority</strong> you\'d
<br>like information from. <strong>By law, they have to respond</strong>
- (<a href="/help/about">why?</a>).
+ (<a href="/help/about">why?</a>).') %>
<br>
<br>
diff --git a/config/environment.rb b/config/environment.rb
index 4f72d030b..af214aded 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -6,7 +6,7 @@
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '2.3.11' unless defined? RAILS_GEM_VERSION
+RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
@@ -17,7 +17,7 @@ $:.push(File.join(File.dirname(__FILE__), '../commonlib/rblib'))
# (type "git submodule update --init" in the whatdotheyknow directory)
# ruby-ole and ruby-msg. We use a custom ruby-msg to avoid a name conflict
-$:.unshift(File.join(File.dirname(__FILE__), '../commonlib/rblib/ruby-ole/lib'))
+$:.unshift(File.join(File.dirname(__FILE__), '../vendor/ruby-ole/lib'))
$:.unshift(File.join(File.dirname(__FILE__), '../vendor/ruby-msg/lib'))
require 'memcache'
@@ -51,18 +51,13 @@ Rails::Initializer.run do |config|
#
# Specify gems that this application depends on and have them installed with rake gems:install
config.gem "fast_gettext", :version => '>=0.4.8'
- config.gem "rack", :version => '1.1.0'
- config.gem "recaptcha", :lib => "recaptcha/rails"
- config.gem 'rspec', :lib => false, :version => '1.3.1'
- config.gem 'rspec-rails', :lib => false, :version => '1.3.3'
- config.gem 'will_paginate', :version => '~> 2.3.11', :source => 'http://gemcutter.org'
-
+ #GettextI18nRails.translations_are_html_safe = true
# Your secret key for verifying cookie session data integrity.
# If you change this key, all old sessions will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
config.action_controller.session = {
- :key => '_wdtk_cookie_session',
+ :session_key => '_wdtk_cookie_session',
:secret => MySociety::Config.get("COOKIE_STORE_SESSION_SECRET", 'this default is insecure as code is open source, please override for live sites in config/general; this will do for local development')
}
config.action_controller.session_store = :cookie_store
@@ -70,7 +65,7 @@ Rails::Initializer.run do |config|
# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
- config.active_record.schema_format = :sql
+ # config.active_record.schema_format = :sql
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector
@@ -117,6 +112,7 @@ require 'tmail_extensions.rb'
require 'activesupport_cache_extensions.rb'
require 'public_body_categories.rb'
require 'timezone_fixes.rb'
+require 'fcgi_fixes.rb'
require 'use_spans_for_errors.rb'
require 'make_html_4_compliant.rb'
require 'activerecord_errors_extensions.rb'
diff --git a/config/environments/development.rb b/config/environments/development.rb
index d15af3336..d5f2f5772 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -21,3 +21,5 @@ config.action_mailer.delivery_method = :sendmail # so is queued, rather than giv
# unintentionally kept references to objects, especially strings.
# require 'memory_profiler'
# MemoryProfiler.start :string_debug => true, :delay => 10
+
+config.gem "gettext", :version => '>=1.9.3', :lib => false
diff --git a/config/initializers/fast_gettext.rb b/config/initializers/fast_gettext.rb
index 9ce0955e9..b01b129fa 100644
--- a/config/initializers/fast_gettext.rb
+++ b/config/initializers/fast_gettext.rb
@@ -1,3 +1,3 @@
-FastGettext.add_text_domain 'app', :path => File.join(RAILS_ROOT, 'locale'), :type => :po
-FastGettext.default_available_locales = ['en'] #all you want to allow
-FastGettext.default_text_domain = 'app' \ No newline at end of file
+FastGettext.add_text_domain 'app', :path => 'locale', :type => :po
+FastGettext.default_available_locales = ['en','es'] #all you want to allow
+FastGettext.default_text_domain = 'app'
diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake
new file mode 100644
index 000000000..017e7c837
--- /dev/null
+++ b/lib/tasks/gettext.rake
@@ -0,0 +1,5 @@
+namespace :gettext do
+ def files_to_translate
+ Dir.glob("{app,lib,config,locale}/**/*.{rb,erb,haml,rhtml}")
+ end
+end \ No newline at end of file
diff --git a/locale/app.pot b/locale/app.pot
index 86952a61d..5a9648766 100644
--- a/locale/app.pot
+++ b/locale/app.pot
@@ -150,5 +150,4 @@ msgid ""
msgstr ""
msgid "activerecord.errors.full_messages.format"
-msgstr "%{message}"
-
+msgstr "%{message}" \ No newline at end of file
diff --git a/locale/es/app.po b/locale/es/app.po
new file mode 100644
index 000000000..9f9e089f0
--- /dev/null
+++ b/locale/es/app.po
@@ -0,0 +1,381 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: version 0.0.1\n"
+"POT-Creation-Date: 2011-01-12 15:14-0000\n"
+"PO-Revision-Date: 2011-01-12 13:06-0000\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
+
+#: locale/model_attributes.rb:45
+msgid "CensorRule|Last edit comment"
+msgstr ""
+
+#: locale/model_attributes.rb:44
+msgid "CensorRule|Last edit editor"
+msgstr ""
+
+#: locale/model_attributes.rb:43
+msgid "CensorRule|Replacement"
+msgstr ""
+
+#: locale/model_attributes.rb:42
+msgid "CensorRule|Text"
+msgstr ""
+
+#: locale/model_attributes.rb:28
+msgid "Comment|Body"
+msgstr ""
+
+#: locale/model_attributes.rb:27
+msgid "Comment|Comment type"
+msgstr ""
+
+#: locale/model_attributes.rb:29
+msgid "Comment|Visible"
+msgstr ""
+
+#: locale/model_attributes.rb:64
+msgid "EximLogDone|Filename"
+msgstr ""
+
+#: locale/model_attributes.rb:65
+msgid "EximLogDone|Last stat"
+msgstr ""
+
+#: locale/model_attributes.rb:19
+msgid "EximLog|Line"
+msgstr ""
+
+#: locale/model_attributes.rb:18
+msgid "EximLog|Order"
+msgstr ""
+
+#: app/views/general/frontpage.rhtml:8
+msgid ""
+"First, type in the <strong>name of the UK public authority</strong> you'd \n"
+" <br>like information from. <strong>By law, they have to respond</"
+"strong>\n"
+" (<a href=\"/help/about\">why?</a>)."
+msgstr ""
+"Firsto, si poco <strong>nomo de the Espanic public authoritita</strong> tu \n"
+" <br>amo informatia. <strong>Par legal, se obligado respondre</"
+"strong>\n"
+" (<a href=\"/help/about\">por acqui?</a>)."
+
+#: locale/model_attributes.rb:61
+msgid "Holiday|Day"
+msgstr ""
+
+#: locale/model_attributes.rb:62
+msgid "Holiday|Description"
+msgstr ""
+
+#: locale/model_attributes.rb:57
+msgid "IncomingMessage|Cached attachment text clipped"
+msgstr ""
+
+#: locale/model_attributes.rb:58
+msgid "IncomingMessage|Cached main body text folded"
+msgstr ""
+
+#: locale/model_attributes.rb:59
+msgid "IncomingMessage|Cached main body text unfolded"
+msgstr ""
+
+#: locale/model_attributes.rb:38
+msgid "InfoRequestEvent|Calculated state"
+msgstr ""
+
+#: locale/model_attributes.rb:37
+msgid "InfoRequestEvent|Described state"
+msgstr ""
+
+#: locale/model_attributes.rb:35
+msgid "InfoRequestEvent|Event type"
+msgstr ""
+
+#: locale/model_attributes.rb:39
+msgid "InfoRequestEvent|Last described at"
+msgstr ""
+
+#: locale/model_attributes.rb:36
+msgid "InfoRequestEvent|Params yaml"
+msgstr ""
+
+#: locale/model_attributes.rb:40
+msgid "InfoRequestEvent|Prominence"
+msgstr ""
+
+#: locale/model_attributes.rb:86
+msgid "InfoRequest|Allow new responses from"
+msgstr ""
+
+#: locale/model_attributes.rb:82
+msgid "InfoRequest|Awaiting description"
+msgstr ""
+
+#: locale/model_attributes.rb:81
+msgid "InfoRequest|Described state"
+msgstr ""
+
+#: locale/model_attributes.rb:87
+msgid "InfoRequest|Handle rejected responses"
+msgstr ""
+
+#: locale/model_attributes.rb:85
+msgid "InfoRequest|Law used"
+msgstr ""
+
+#: locale/model_attributes.rb:83
+msgid "InfoRequest|Prominence"
+msgstr ""
+
+#: locale/model_attributes.rb:80
+msgid "InfoRequest|Title"
+msgstr ""
+
+#: locale/model_attributes.rb:84
+msgid "InfoRequest|Url title"
+msgstr ""
+
+#: app/views/general/frontpage.rhtml:4
+msgid "Make or explore Freedom of Information requests"
+msgstr "Un grande informationo qui reparare"
+
+#: locale/model_attributes.rb:21
+msgid "OutgoingMessage|Body"
+msgstr ""
+
+#: locale/model_attributes.rb:24
+msgid "OutgoingMessage|Last sent at"
+msgstr ""
+
+#: locale/model_attributes.rb:23
+msgid "OutgoingMessage|Message type"
+msgstr ""
+
+#: locale/model_attributes.rb:22
+msgid "OutgoingMessage|Status"
+msgstr ""
+
+#: locale/model_attributes.rb:25
+msgid "OutgoingMessage|What doing"
+msgstr ""
+
+#: locale/model_attributes.rb:55
+msgid "PostRedirect|Circumstance"
+msgstr ""
+
+#: locale/model_attributes.rb:53
+msgid "PostRedirect|Email token"
+msgstr ""
+
+#: locale/model_attributes.rb:52
+msgid "PostRedirect|Post params yaml"
+msgstr ""
+
+#: locale/model_attributes.rb:54
+msgid "PostRedirect|Reason params yaml"
+msgstr ""
+
+#: locale/model_attributes.rb:50
+msgid "PostRedirect|Token"
+msgstr ""
+
+#: locale/model_attributes.rb:51
+msgid "PostRedirect|Uri"
+msgstr ""
+
+#: locale/model_attributes.rb:15
+msgid "ProfilePhoto|Data"
+msgstr ""
+
+#: locale/model_attributes.rb:16
+msgid "ProfilePhoto|Draft"
+msgstr ""
+
+#: locale/model_attributes.rb:12
+msgid "PublicBody|First letter"
+msgstr ""
+
+#: locale/model_attributes.rb:10
+msgid "PublicBody|Home page"
+msgstr ""
+
+#: locale/model_attributes.rb:8
+msgid "PublicBody|Last edit comment"
+msgstr ""
+
+#: locale/model_attributes.rb:7
+msgid "PublicBody|Last edit editor"
+msgstr ""
+
+#: locale/model_attributes.rb:3
+msgid "PublicBody|Name"
+msgstr ""
+
+#: locale/model_attributes.rb:11
+msgid "PublicBody|Notes"
+msgstr ""
+
+#: locale/model_attributes.rb:13
+msgid "PublicBody|Publication scheme"
+msgstr ""
+
+#: locale/model_attributes.rb:5
+msgid "PublicBody|Request email"
+msgstr ""
+
+#: locale/model_attributes.rb:4
+msgid "PublicBody|Short name"
+msgstr ""
+
+#: locale/model_attributes.rb:9
+msgid "PublicBody|Url name"
+msgstr ""
+
+#: locale/model_attributes.rb:6
+msgid "PublicBody|Version"
+msgstr ""
+
+#: locale/model_attributes.rb:48
+msgid "RawEmail|Data binary"
+msgstr ""
+
+#: locale/model_attributes.rb:47
+msgid "RawEmail|Data text"
+msgstr ""
+
+#: locale/model_attributes.rb:32
+msgid "TrackThing|Track medium"
+msgstr ""
+
+#: locale/model_attributes.rb:31
+msgid "TrackThing|Track query"
+msgstr ""
+
+#: locale/model_attributes.rb:33
+msgid "TrackThing|Track type"
+msgstr ""
+
+#: locale/model_attributes.rb:67
+msgid "UserInfoRequestSentAlert|Alert type"
+msgstr ""
+
+#: locale/model_attributes.rb:78
+msgid "User|About me"
+msgstr ""
+
+#: locale/model_attributes.rb:76
+msgid "User|Admin level"
+msgstr ""
+
+#: locale/model_attributes.rb:77
+msgid "User|Ban text"
+msgstr ""
+
+#: locale/model_attributes.rb:69
+msgid "User|Email"
+msgstr ""
+
+#: locale/model_attributes.rb:73
+msgid "User|Email confirmed"
+msgstr ""
+
+#: locale/model_attributes.rb:71
+msgid "User|Hashed password"
+msgstr ""
+
+#: locale/model_attributes.rb:75
+msgid "User|Last daily track email"
+msgstr ""
+
+#: locale/model_attributes.rb:70
+msgid "User|Name"
+msgstr ""
+
+#: locale/model_attributes.rb:72
+msgid "User|Salt"
+msgstr ""
+
+#: locale/model_attributes.rb:74
+msgid "User|Url name"
+msgstr ""
+
+#: locale/model_attributes.rb:41
+msgid "censor rule"
+msgstr ""
+
+#: locale/model_attributes.rb:26
+msgid "comment"
+msgstr ""
+
+#: locale/model_attributes.rb:17
+msgid "exim log"
+msgstr ""
+
+#: locale/model_attributes.rb:63
+msgid "exim log done"
+msgstr ""
+
+#: app/controllers/general_controller.rb:40
+msgid "foo"
+msgstr "foolo"
+
+#: locale/model_attributes.rb:60
+msgid "holiday"
+msgstr ""
+
+#: locale/model_attributes.rb:56
+msgid "incoming message"
+msgstr ""
+
+#: locale/model_attributes.rb:79
+msgid "info request"
+msgstr ""
+
+#: locale/model_attributes.rb:34
+msgid "info request event"
+msgstr ""
+
+#: locale/model_attributes.rb:20
+msgid "outgoing message"
+msgstr ""
+
+#: locale/model_attributes.rb:49
+msgid "post redirect"
+msgstr ""
+
+#: locale/model_attributes.rb:14
+msgid "profile photo"
+msgstr ""
+
+#: locale/model_attributes.rb:2
+msgid "public body"
+msgstr ""
+
+#: locale/model_attributes.rb:46
+msgid "raw email"
+msgstr ""
+
+#: locale/model_attributes.rb:30
+msgid "track thing"
+msgstr ""
+
+#: locale/model_attributes.rb:68
+msgid "user"
+msgstr ""
+
+#: locale/model_attributes.rb:66
+msgid "user info request sent alert"
+msgstr ""
diff --git a/script/generate_pot.sh b/script/generate_pot.sh
new file mode 100644
index 000000000..69b603748
--- /dev/null
+++ b/script/generate_pot.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+cd `dirname $0`
+
+rake gettext:store_model_attributes
+rake gettext:find
+
+
+rake translate_routes:update_yaml["en es"] \ No newline at end of file