Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 1354 Bytes
1 | module Localization |
2 | mattr_accessor :lang |
3 | |
4 | @@l10s = { :default => {} } |
5 | @@lang = :default |
6 | |
7 | def self._(string_to_localize, *args) |
8 | translated = @@l10s[@@lang][string_to_localize] || string_to_localize |
9 | return translated.call(*args).to_s if translated.is_a? Proc |
10 | if translated.is_a? Array |
11 | translated = if translated.size == 3 |
12 | translated[args[0]==0 ? 0 : (args[0]>1 ? 2 : 1)] |
13 | else |
14 | translated[args[0]>1 ? 1 : 0] |
15 | end |
16 | end |
17 | sprintf translated, *args |
18 | end |
19 | |
20 | def self.define(lang = :default) |
21 | @@l10s[lang] ||= {} |
22 | yield @@l10s[lang] |
23 | end |
24 | |
25 | def self.load |
26 | Dir.glob("#{RAILS_ROOT}/lang/*.rb"){ |t| require t } |
27 | Dir.glob("#{RAILS_ROOT}/lang/custom/*.rb"){ |t| require t } |
28 | end |
29 | |
30 | # Generates a best-estimate l10n file from all views by |
31 | # collecting calls to _() -- note: use the generated file only |
32 | # as a start (this method is only guesstimating) |
33 | def self.generate_l10n_file |
34 | "Localization.define('en_US') do |l|\n" << |
35 | Dir.glob("#{RAILS_ROOT}/app/views/**/*.rhtml").collect do |f| |
36 | ["# #{f}"] << File.read(f).scan(/<%.*[^\w]_\s*[\"\'](.*?)[\"\']/) |
37 | end.uniq.flatten.collect do |g| |
38 | g.starts_with?('#') ? "\n #{g}" : " l.store '#{g}', '#{g}'" |
39 | end.uniq.join("\n") << "\nend" |
40 | end |
41 | |
42 | end |
43 | |
44 | class Object |
45 | def _(*args); Localization._(*args); end |
46 | end |