rails i18n Web 界面
Translate your apps with pleasure (sort of...) and for free. It's simple i18n web interface, build on top of twitter bootstrap, that one may find helpful in translating app by non-technicals.
Highly inspired by Copycopter by thoughtbot.
date.abbr_day_names)Check wiki for more: Screenshots
lit gem to your Gemfilegem 'lit'For Ruby 1.2.4'
...we also support V2 of Google Cloud Translate gem, should you need it:gem 'google-cloud-translate', '~> 2.1.2'
To use translation via Google, you need to obtain a [service account key](https://cloud.google.com/iam/docs/creating-managing-service-account-keys) containing all the credentials required by the API.
These credentials can be given in three ways:
* via a `.json` keyfile, the path to which should be stored in the `GOOGLE_TRANSLATE_API_KEYFILE` environment variable,
* programmatically, in the initializer - be sure to use secrets in all the sensitive fields so you don't expose private credentials in the code:Lit::CloudTranslation.configure do |config| config.keyfile_hash = { 'type' => 'service_account', 'project_id' => 'foo', 'private_key_id' => 'keyid', ... # see Google docs link above for reference } end
the credentials.config could be strings or, as well, symbols):
Lit::CloudTranslation.configure do |config| config.keyfile_hash = HashWithIndifferentAccess.new(Rails.application.credentials.config[:google_translate_api]) end
* directly via `GOOGLE_TRANSLATE_API_` environment variables, where e.g. the `GOOGLE_TRANSLATE_API_PROJECT_ID` variable corresponds to the `project_id` element of a JSON keyfile. Typically, only the following variables are mandatory:
* `GOOGLE_TRANSLATE_API_PROJECT_ID`
* `GOOGLE_TRANSLATE_API_PRIVATE_KEY` (make sure that it contains correct line breaks and markers of the private key's begin and end)
* `GOOGLE_TRANSLATE_API_CLIENT_EMAIL`
#### Yandex.Translate API
Insert this into your Lit initializer:require 'lit/cloud_translation/providers/yandex'
Lit::CloudTranslation.provider = Lit::CloudTranslation::Providers::Yandex
To use Yandex translation, an [API key must be obtained](https://translate.yandex.com/developers/keys). Then, you can pass it to your application via the `YANDEX_TRANSLATE_API_KEY` environment variable.
The API key can also be set programmatically in your Lit initializer (again, be sure to use secrets if you choose to do so):Lit::CloudTranslation.configure do |config| config.api_key = 'the_api_key' end
…Lit::Localization.group(:locale_id, :localization_key_id).having('count(*) > 1').count
### 0.2 -> 0.3 upgrade guide
1. Specify exact lit version in your Gemfile: `gem 'lit', '~> 0.3.0'`
2. Run `bundle update lit`
3. Add `config.i18n.available_locales` to your `application.rb` (see 3rd point from Installation info)
4. Add `config.i18n.enforce_available_locales = true` config to your `application.rb`
5. Compare your current `lit.rb` initializer with [template](https://github.com/prograils/lit/blob/master/lib/generators/lit/install/templates/initializer.rb).
### On-site live translations
1. Add `Lit::FrontendHelper` to your `ApplicationController`
```ruby
helper Lit::FrontendHelper
…
ruby
include Lit::RequestInfoStorelit.rb) set store_request_info config to trueLit.store_request_info = trueLit::FrontendHelper in your ApplicationControllerhelper Lit::FrontendHelperLit::RequestKeysStore concern in your ApplicationControllerinclude Lit::RequestKeysStoreconfig/initializers/lit.rbLit.store_request_keys = truelit_translations_info helper functionFrom now on you'll be able to see all translation keys that were used to render current page. This feature works great with on-site live translations!
Lit authorized user must be signed in for this feature to work! This feature requires jQuery!
date.abbr_day_names)I18n.t('not_exising_keys', default: lambda{|_, options| 'text'}) )gem install bundler && bundle install - ensure Bundler and all required gems are installedbundle exec appraisal install - install gems from appraisal's gemfilescp test/dummy/config/database.yml.sample test/dummy/config/database.yml - move a database.yml in place (remember to fill your DB credentials in it)RAILS_ENV=test bundle exec appraisal rails-7.0 rake db:setup - setup lit DB (see test/config/database.yml); do it
only once, it does not matter which Rails version you use for appraisalbundle exec appraisal rake - run the tests!Lit is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
暂无开放 Issues,或尚未同步最近议题。