From 43db60b5456d8970d4de01091be735ca65309c97 Mon Sep 17 00:00:00 2001 From: Baptiste Gelez Date: Sun, 27 Jan 2019 21:47:02 +0100 Subject: [PATCH] Fix i18n --- Gemfile | 1 - README.md | 6 ++++++ config.rb | 23 +++++++++-------------- source/{ => localizable}/_nav.erb | 0 source/{ => localizable}/index.html.erb | 0 5 files changed, 15 insertions(+), 15 deletions(-) rename source/{ => localizable}/_nav.erb (100%) rename source/{ => localizable}/index.html.erb (100%) diff --git a/Gemfile b/Gemfile index 892d849..180cfa2 100644 --- a/Gemfile +++ b/Gemfile @@ -4,4 +4,3 @@ gem 'middleman', '~> 4.2' gem 'middleman-autoprefixer', '~> 2.7' gem 'tzinfo-data', platforms: [:mswin, :mingw, :jruby] gem 'wdm', '~> 0.1', platforms: [:mswin, :mingw] -gem 'gettext', '~> 3.2' diff --git a/README.md b/README.md index 1759805..9bcdf32 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,10 @@ like to contribute. It is using middleman. +## Usefull commands + +- `./i18n.sh` to update .pot, .po and .mo files +- `middleman` for live preview during development +- `middleman build` when deploying + TODO: automatic deployment https://github.com/hovancik/middleman-github-deploy diff --git a/config.rb b/config.rb index 0fdec9d..f83b82c 100644 --- a/config.rb +++ b/config.rb @@ -1,25 +1,20 @@ -require "gettext" -require "middleman-core/sitemap/extensions/proxies" +require "i18n" -GetText::bindtextdomain 'joinplume', { path: 'translations' } +I18n::Backend::Simple.include(I18n::Backend::Gettext) +I18n.load_path << Dir["po/*.po"] # Load all PO file in current directory -ready do - File.readlines('po/LINGUAS').each do |lang| - lang = lang.strip - GetText::set_locale lang - puts(GetText::_("A federated blogging application")) - sitemap.resources.select{ |r| !r.respond_to?(:target_resource) && r.ext == ".html" }.each do |res| - proxy "#{lang}/#{res.destination_path}", res.path, {} - end - end -end +activate :i18n, + :langs => [:en, :es, :fr], + :path => "/:locale/", + :no_fallbacks => true, + :data => "po" activate :autoprefixer do |prefix| prefix.browsers = "last 2 versions" end helpers do - include GetText + include I18n::Gettext::Helpers end # configure :build do diff --git a/source/_nav.erb b/source/localizable/_nav.erb similarity index 100% rename from source/_nav.erb rename to source/localizable/_nav.erb diff --git a/source/index.html.erb b/source/localizable/index.html.erb similarity index 100% rename from source/index.html.erb rename to source/localizable/index.html.erb