README.markdown in grosser-fast_gettext-0.3.8 vs README.markdown in grosser-fast_gettext-0.4.0
- old
+ new
@@ -103,17 +103,38 @@
is sufficient and no more `text_domain=` is needed
###default_locale
If the simple rule of "first `availble_locale` or 'en'" is not suficcient for you, simply set `FastGettext.default_locale = 'de'`.
+###Chains
+You can use any number of repositories to find a translation. Simply add them to a chain and when
+the first cannot translate a given key, the next is asked and so forth.
+ repos = [
+ FastGettext::TranslationRepository.build('old', :path=>'....'),
+ FastGettext::TranslationRepository.build('new', :path=>'....')
+ ]
+ FastGettext.add_text_domain 'combined', :type=>:chain, :chain=>repos
+
+#Logger
+When you want to know which keys could not be translated, or where used, add a Logger to a Chain:
+ repos = [
+ FastGettext::TranslationRepository.build('app', :path=>'....')
+ FastGettext::TranslationRepository.build('logger', :type=>:logger, :callback=>lamda{|msgid_or_array_of_ids| ... }),
+ }
+ FastGettext.add_text_domain 'combined', :type=>:chain, :chain=>repos
+If the Logger is in position #1 it will see all translations, if it is in position #2 it will only see the unfound.
+Unfound may not always mean missing, if you chose not to translate a word because the msgid is a good translation, it will appear nevertheless.
+A lambda or anything that responds to `call` will do as callback.
+
###Plugins
Want a yml, xml, database version ?
Write your own TranslationRepository!
#fast_gettext/translation_repository/xxx.rb
module FastGettext
module TranslationRepository
class Wtf
- define initialize(name,options), available_locales, [key], plural(*msgids)
+ define initialize(name,options), [key], plural(*msgids) and
+ either inherit from Base or define available_locales and pluralisation rule
end
end
end
FAQ