diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c571ca8..0f41405 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,12 +11,14 @@ jobs: strategy: matrix: database: [ mysql, postgresql ] - ruby: [ 2.7, 2.6 ] + ruby: [ 3.2, 3.1, 3.0, 2.7 ] fail-fast: false max-parallel: 20 runs-on: ubuntu-latest env: + BUNDLE_JOBS: 4 + BUNDLE_PATH: vendor/bundle CI: true DB: ${{ matrix.database }} MYSQL_PASSWORD: root diff --git a/.gitignore b/.gitignore index 4988a35..b9efa5f 100644 --- a/.gitignore +++ b/.gitignore @@ -87,3 +87,83 @@ spec/dummy # Local Gemfile for developing without sharing dependencies .gemfile +# Rails +.bundle +db/*.sqlite3 +db/*.sqlite3-journal +*.log +tmp +tmp/**/* + +# Documentation +doc/api +doc/app +.yardoc +.yardopts +coverage + +# Public Uploads +public/system/* +public/themes/* + +# Public Cache +public/javascripts/cache +public/stylesheets/cache +public/refinery/* + +# Vendor Cache +vendor/cache + +# Acts as Indexed +index/**/* + +# Refinery Specific +*.tmproj +*.autobackupbyrefinery.* +refinerycms-*.gem + +# Mac +.DS_Store + +# Windows +Thumbs.db + +# NetBeans +nbproject + +# Eclipse +.project + +# Redcar +.redcar + +# Rubinius +*.rbc + +# Vim +*.swp +*.swo + +# RubyMine +.idea + +# E-texteditor +.eprj + +# Backup +*~ + +# Capybara Bug +capybara-*html + +# sass +.sass-cache +.sass-cache/* + +#rvm +.rvmrc +.rvmrc.* + +# vendor/extensions dummy applications. +vendor/extensions/**/spec/dummy + diff --git a/Gemfile b/Gemfile index f16ce01..c32ce2c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,7 @@ source "https://rubygems.org" - gemspec - -git "https://github.com/refinery/refinerycms", branch: "master" do +# +git "https://github.com/anitagraham/refinerycms", branch: "ruby3" do gem "refinerycms" group :test do diff --git a/README.md b/README.md index a95cc47..eaa0b09 100644 --- a/README.md +++ b/README.md @@ -10,15 +10,37 @@ rails g refinery:i18n ```ruby Refinery::I18n.configure do |config| - config.default_locale = :en + config.default_locale = :en # config.current_locale = :en # config.default_frontend_locale = :en - config.frontend_locales = [:en,:ar] + config.frontend_locales = [:en, :ar] - config.locales = {:en=>"English", :ar=>"Arabic"} - #, :nl=>"Nederlands", :pt=>"Português", :"pt-BR"=>"Português brasileiro", :da=>"Dansk", :nb=>"Norsk Bokmål", :sl=>"Slovenian", :es=>"Español", :it=>"Italiano", :de=>"Deutsch", :lv=>"Latviski", :ru=>"Русский", :sv=>"Svenska", :pl=>"Polski", :"zh-CN"=>"简体中文", :"zh-TW"=>"繁體中文", :el=>"Ελληνικά", :rs=>"Srpski", :cs=>"Česky", :sk=>"Slovenský", :ja=>"日本語", :bg=>"Български", :hu=>"Hungarian", :uk=>"Українська"} + config.locales = { en: "English", ar: "Arabic" } + # { nl: "Nederlands", + # pt: "Português", + # "pt-BR": "Português brasileiro", + # da: "Dansk", + # nb: "Norsk Bokmål", + # sl: "Slovenian", + # es: "Español", + # it: "Italiano", + # de: "Deutsch", + # lv: "Latviski", + # ru: "Русский", + # sv: "Svenska", + # pl: "Polski", + # "zh-CN": "简体中文", + # "zh-TW": "繁體中文", + # el: "Ελληνικά", + # rs: "Srpski", + # cs: "Česky", + # sk: "Slovenský", + # ja: "日本語", + # bg: "Български", + # hu: "Hungarian", + # uk: "Українська" } end ``` diff --git a/Rakefile b/Rakefile index 30b03df..9032493 100644 --- a/Rakefile +++ b/Rakefile @@ -8,9 +8,7 @@ end ENGINE_PATH = File.dirname(__FILE__) APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__) -if File.exists?(APP_RAKEFILE) - load 'rails/tasks/engine.rake' -end +load 'rails/tasks/engine.rake' if File.exist?(APP_RAKEFILE) require "refinerycms-testing" Refinery::Testing::Railtie.load_dummy_tasks(ENGINE_PATH) diff --git a/lib/refinery/i18n-filter.rb b/lib/refinery/i18n-filter.rb index 6b0253c..a03d5a0 100644 --- a/lib/refinery/i18n-filter.rb +++ b/lib/refinery/i18n-filter.rb @@ -27,7 +27,7 @@ def around_generate(params, &block) if ::Refinery::I18n.url_filter_enabled? and locale != ::Refinery::I18n.default_frontend_locale and result !~ %r{^/(#{Refinery::Core.backend_route}|wymiframe)} - result.url.sub!(%r(^(http.?://[^/]*)?(.*))) { "#{$1}/#{locale}#{$2}" } + result.sub!(%r(^(http.?://[^/]*)?(.*))) { "#{$1}/#{locale}#{$2}" } end end end diff --git a/refinerycms-i18n.gemspec b/refinerycms-i18n.gemspec index 79a4c1a..42fbe88 100644 --- a/refinerycms-i18n.gemspec +++ b/refinerycms-i18n.gemspec @@ -14,11 +14,11 @@ Gem::Specification.new do |s| s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- spec/*`.split("\n") - s.required_ruby_version = '>= 2.2.9' + s.required_ruby_version = '>= 2.7' s.add_dependency 'routing-filter', '~> 0.6' s.add_dependency 'rails-i18n', '>= 5.0' - s.add_dependency 'mobility', '~> 0.8.8' + s.add_dependency 'mobility', '~> 1.2.9' s.cert_chain = [File.expand_path("../certs/parndt.pem", __FILE__)] if $0 =~ /gem\z/ && ARGV.include?("build") && ARGV.include?(__FILE__) diff --git a/spec/features/set_locale_spec.rb b/spec/features/set_locale_spec.rb index d36497c..0ceae47 100644 --- a/spec/features/set_locale_spec.rb +++ b/spec/features/set_locale_spec.rb @@ -1,7 +1,7 @@ # encoding: utf-8 require "spec_helper" -describe "set_locale parameter", :type => :feature do +describe "set_locale parameter", type: :feature do refinery_login it "changes language used in backend" do @@ -9,7 +9,7 @@ expect(page).to have_content("Switch to your website") - visit refinery.admin_pages_path(:set_locale => :cs) + visit refinery.admin_pages_path(set_locale: :cs) expect(page).to have_content("Přepnout na web") end diff --git a/translate-readme.md b/translate-readme.md index a7dd452..eceb385 100644 --- a/translate-readme.md +++ b/translate-readme.md @@ -1,9 +1,10 @@ Translate ========= -This plugin provides a web interface for translating Rails I18n texts (requires Rails 2.2 or higher) from one locale to another. The plugin has been tested only with the simple I18n backend that ships with Rails. I18n texts are read from and written to YAML files under config/locales. +This plugin provides a web interface for translating Rails I18n texts (requires Rails 2.2 or higher) from one locale to another. The plugin has been tested only with the simple I18n backend that ships with Rails. I18n texts are read from and written to YAML files under `config/locales`. -To translate to a new locale you need to add a YAML file for that locale that contains the locale as the top key and at least one translation. +To translate to a new locale you need to add a YAML file for that locale. +A translation file has the _locale_ as the top key and at least one translation. Please note that there are certain I18n keys that map to Array objects rather than strings and those are currently not dealt with by the translation UI. This means that Rails built in keys such as date.day_names need to be translated manually directly in the YAML file. @@ -19,21 +20,29 @@ Rake Tasks In addition to the web UI this plugin adds the following rake tasks: -translate:lost_in_translation -translate:merge_keys -translate:google -translate:changed +* translate:lost_in_translation +* translate:merge_keys +* translate:google +* translate:changed -The lost_in_translation task shows you any I18n keys in your code that are do not have translations in the YAML file for your default locale, i.e. config/locales/sv.yml. +### Lost in Translation +The `translate:lost_in_translation` task shows you any I18n keys in your code that are do not have translations in the YAML file for your default locale, i.e. config/locales/sv.yml. -The merge_keys task is supposed to be used in conjunction with Sven Fuch's Rails I18n TextMate bundle (http://github.com/svenfuchs/rails-i18n/tree/master). Texts and keys extracted with the TextMate bundle end up in the temporary file log/translations.yml. When you run the merge_keys rake task the keys are moved over to the corresponding I18n locale file, i.e. config/locales/sv.yml. The merge_keys task also checks for overwrites of existing keys by warning you that one of your extracted keys already exists with a different translation. +### Merge Keys +The `translate:merge_keys` task is supposed to be used in conjunction with Sven Fuch's [Rails I18n TextMate bundle](http://github.com/svenfuchs/rails-i18n/tree/master). -The google task is used for auto translating from one locale to another using Google Translate. +Texts and keys extracted with the TextMate bundle end up in a temporary file `log/translations.yml`. +When you run the `merge_keys` rake task these keys are moved to the corresponding I18n locale file, i.e. `config/locales/sv.yml`. +The `merge_keys` task also warns you if one of your extracted keys will overwrite an existing translation. -The changed rake task can show you between one YAML file to another which keys have had their texts changed. +### Translate Google +The `translate:google` task is used for auto translating from one locale to another using Google Translate. + +### Translate Changed +The `translate:changed` task can show you which keys have had their texts changed between one file and another. + +## Installation -Installation -========= Obtain the source with: ./script/plugin install git://github.com/newsdesk/translate.git