From 26d2df4e0ad3ba7ecc0969f6a7bde792e6031383 Mon Sep 17 00:00:00 2001 From: Tomasz Gieniusz Date: Sat, 20 Oct 2012 10:34:14 +0200 Subject: [PATCH] i18n added --- config/locales/en.yml | 2 ++ git_stats.gemspec | 1 + lib/git_stats.rb | 1 + lib/git_stats/core_extensions/symbol.rb | 5 +++++ lib/git_stats/i18n.rb | 1 + templates/index.haml | 2 +- 6 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 config/locales/en.yml create mode 100644 lib/git_stats/core_extensions/symbol.rb create mode 100644 lib/git_stats/i18n.rb diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 000000000..272910996 --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,2 @@ +en: + project_name: Project name \ No newline at end of file diff --git a/git_stats.gemspec b/git_stats.gemspec index 424adb433..039a31a62 100644 --- a/git_stats.gemspec +++ b/git_stats.gemspec @@ -23,6 +23,7 @@ Gem::Specification.new do |gem| gem.add_dependency('haml') gem.add_dependency('launchy') gem.add_dependency('lazy_high_charts') + gem.add_dependency('i18n') gem.add_development_dependency('rake') gem.add_development_dependency('pry') diff --git a/lib/git_stats.rb b/lib/git_stats.rb index ea51f0e76..c93ddf383 100644 --- a/lib/git_stats.rb +++ b/lib/git_stats.rb @@ -8,4 +8,5 @@ require 'fileutils' require 'tilt' require 'lazy_high_charts' require 'launchy' +require 'i18n' Dir['lib/**/*.rb'].each { |r| require File.expand_path(r) } \ No newline at end of file diff --git a/lib/git_stats/core_extensions/symbol.rb b/lib/git_stats/core_extensions/symbol.rb new file mode 100644 index 000000000..af856c7d4 --- /dev/null +++ b/lib/git_stats/core_extensions/symbol.rb @@ -0,0 +1,5 @@ +class Symbol + def t + I18n.t self + end +end \ No newline at end of file diff --git a/lib/git_stats/i18n.rb b/lib/git_stats/i18n.rb new file mode 100644 index 000000000..cc1ba0cc3 --- /dev/null +++ b/lib/git_stats/i18n.rb @@ -0,0 +1 @@ +I18n.load_path += Dir['config/locales/*.yml'] \ No newline at end of file diff --git a/templates/index.haml b/templates/index.haml index c3354dea6..d9377d158 100644 --- a/templates/index.haml +++ b/templates/index.haml @@ -1,6 +1,6 @@ %table{:class => "table table-hover table-bordered"} %tr - %td Project name + %td= :project_name.t %td= repo.project_name %tr %td Project version