Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby3 #104

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Ruby3 #104

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
80 changes: 80 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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

5 changes: 2 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
4 changes: 1 addition & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/refinery/i18n-filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions refinerycms-i18n.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
4 changes: 2 additions & 2 deletions spec/features/set_locale_spec.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# 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
visit refinery.admin_pages_path

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
Expand Down
33 changes: 21 additions & 12 deletions translate-readme.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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
Expand Down
Loading