Project

General

Profile

« Previous | Next » 

Revision c2f9dd87

Added by Marc Dequènes almost 14 years ago

  • ID c2f9dd871aeff90135d85c2fa43ce6ad62e35e30

[evol] I18n: new helpers to setup gettext domains and deferred translations (and one to inject the correct domain into specific core classes in order to be able to use cyborg-local translations into them (currently only needed for DSL classes))

View differences:

IDEAS
misc:
- rename schedule_task to schedule_job, as the <task> argument is not a DSL::Task
or transform it into a real task
all bots:
- API:
* list manipulators:
bin/clerk
module CyborgHood
module DSL
include I18nTranslation
bindtextdomain("cyborghood_clerk", {:path => Config::L10N_DIR, :output_charset => "UTF-8"})
end
module ClerkLand
include I18nTranslation
bindtextdomain("cyborghood_clerk", {:path => Config::L10N_DIR, :output_charset => "UTF-8"})
class Clerk < Cyborg
# load config before modules are included
Config.load(self.human_name)
inject_deferred_translations
include BotNet
def setup
bin/librarian
module CyborgHood
module LibrarianLand
include I18nTranslation
bindtextdomain("cyborghood_librarian", {:path => Config::L10N_DIR, :output_charset => "UTF-8"})
class Librarian < Cyborg
# load config before modules are included
Config.load(self.human_name)
inject_deferred_translations
include BotNet
def setup
bin/mapmaker
end
module MapMakerLand
include I18nTranslation
bindtextdomain("cyborghood_mapmaker", {:path => Config::L10N_DIR, :output_charset => "UTF-8"})
class MapMaker < Cyborg
# load config before modules are included
Config.load(self.human_name)
inject_deferred_translations
include BotNet
def setup
bin/postman
module CyborgHood
module PostmanLand
include I18nTranslation
bindtextdomain("cyborghood_postman", {:path => Config::L10N_DIR, :output_charset => "UTF-8"})
class Postman < Cyborg
# load config before modules are included
Config.load(self.human_name)
inject_deferred_translations
include BotNet
def setup
bin/test_client
module CyborgHood
module TestClientHome
include I18nTranslation
bindtextdomain("cyborghood_mapmaker", {:path => Config::L10N_DIR, :output_charset => "UTF-8"})
add_translations 'testclient'
class TestClientClient < Cyborg
# load config before modules are included
Config.load
inject_deferred_translations
include BotNet
def start_work
lib/cyborghood-clerk/land.rb
module CyborgHood
module ClerkLand
add_deferred_translations 'clerk'
def register_services(container)
container.namespace_define(:clerk_land) do |b|
b.records do
lib/cyborghood-librarian/land.rb
module CyborgHood
module LibrarianLand
add_deferred_translations 'librarian'
def register_services(container)
container.namespace_define(:librarian_land) do |b|
b.records do
lib/cyborghood-mapmaker/land.rb
module CyborgHood
module MapMakerLand
add_deferred_translations 'mapmaker'
def register_services(container)
container.namespace_define(:mapmaker_land) do |b|
b.dns do
lib/cyborghood-postman/land.rb
module CyborgHood
module PostmanLand
add_deferred_translations 'postman'
def register_services(container)
container.namespace_define(:postman_land) do |b|
b.imap do
lib/cyborghood.rb
require 'cyborghood/base/exceptions'
ENV['LC_ALL'] = "C"
module CyborgHood
include I18nTranslation
ENV['LC_ALL'] = "C"
bindtextdomain("cyborghood", {:path => Config::L10N_DIR, :output_charset => "UTF-8"})
add_deferred_translations
def register_services(container)
container.define do |b|
lib/cyborghood/base/language.rb
require 'http_headers'
# helpers
class Module
include GetText
@@ch_translations = Set.new
def add_translations(domain)
if @@ch_translations.include? domain
textdomain(domain)
else
bindtextdomain(domain, {:path => CyborgHood::Config::L10N_DIR, :output_charset => "UTF-8"})
@@ch_translations << domain
end
end
def add_deferred_translations(cyborg_model = nil)
domain = 'cyborghood'
domain += '_' + cyborg_model if cyborg_model
add_translations(domain)
include CyborgHood::I18nTranslation
end
end
module CyborgHood
class I18nController
include Singleton
lib/cyborghood/cyborg.rb
self.class.model
end
def self.inject_deferred_translations
DSL.add_deferred_translations self.model.downcase
end
# #^.*/system$# categories are reserved
# but you may enhance or break the system as you wish
def get_channel(name)

Also available in: Unified diff