scratch/lib/multi.rb

30 lines
1.1 KiB
Ruby
Raw Normal View History

2009-10-12 15:36:17 +00:00
def tradOf(keyword)
2010-01-19 15:23:37 +00:00
tradOfKeywordIn(keyword, @conf.language )
2009-10-12 15:36:17 +00:00
end
def tradOfKeywordIn(keyword, language)
begin
@config[:translations][keyword][language.intern]
rescue
if @config[:translations].nil?
puts %{ERROR (lib/multi.rb) Please make a 'translations' hash table in config.yaml}
elsif @config[:translations][keyword].nil?
puts %{ERROR (lib/multi.rb) in config.yaml,
in the 'translations' hash, I can't find the keyword #{keyword}}
elsif @config[:translations][keyword][language.intern].nil?
puts %{ERROR (lib/multi.rb) in config.yaml,
in the 'translations' hash, I can't find the translation
in #{language} for the keyword #{keyword}}
else
puts %{ERROR (lib/multi.rb) erreur inconnue}
end
return '[Sorry Translation Error]'
end
end
2010-01-19 15:23:37 +00:00
def item_of_language(language)
searched_path=@item_rep.path.sub(@conf.language,language)
2010-01-20 15:20:44 +00:00
# puts %{source path = #{@item_rep.path}, searched_path = #{searched_path}}
@items.find { |i| i.reps[0].path == searched_path }
2010-01-19 15:23:37 +00:00
end