• Stars
    star
    205
  • Rank 184,198 (Top 4 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 1 year ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Web interface to manage i18n translations helping to facilitate the editors of your translations. Provides a low-tech and complete workflow for importing, translating, and exporting your I18n translation files. Designed to allow you to keep the translation files inside your projects git repository where they should be.

Rails I18n Manager

A complete translation editor and workflow

Gem Version CI Status

Web interface to manage i18n translations helping to facilitate the editors of your translations. Provides a low-tech and complete workflow for importing, translating, and exporting your I18n translation files. Designed to allow you to keep the translation files inside your projects git repository where they should be.

Features:

  • Import & export translations using standard i18n YAML/JSON files
  • Allows managing translations for any number of apps
  • Built in support for Google Translation for missing translations
  • Provides an API end point to perform automated downloads of your translations

Screenshots

Screenshot

Screenshot

Screenshot

Setup

Developed as a Rails engine. So you can add to any existing app or create a brand new app with the functionality.

First add the gem to your Gemfile

### Gemfile
gem "rails_i18n_manager"

Then install and run the database migrations

bundle install
bundle exec rake rails_i18n_manager:install:migrations
bundle exec rake db:migrate

Routes

Option A: Mount to a path

### config/routes.rb

### As sub-path
mount RailsI18nManager::Engine, at: "/rails_i18n_manager", as: "rails_i18n_manager"

### OR as root-path
mount RailsI18nManager::Engine, at: "/", as: "rails_i18n_manager"

Option B: Mount to a subdomain

### config/routes.rb

translations_engine_subdomain = "translations"

mount RailsI18nManager::Engine,
  at: "/", as: "translations_engine",
  constraints: Proc.new{|request| request.subdomain == translations_engine_subdomain }

not_engine = Proc.new{|request| request.subdomain != translations_engine_subdomain }

constraints not_engine do
  # your app routes here...
end

Configuration

### config/initializers/rails_i18n_manager.rb

RailsI18nManager.config do |config|
  config.google_translate_api_key = ENV.fetch("GOOGLE_TRANSLATE_API_KEY", nil)

  ### You can use our built-in list of all locales Google Translate supports
  ### OR make your own list. These need to be supported by Google Translate
  # config.valid_locales = ["en", "es", "fr"]
end

Customizing Authentication

### config/routes.rb

### Using Devise
authenticated :user do
  mount RailsI18nManager::Engine, at: "/rails_i18n_manager", as: "rails_i18n_manager"
end

### Custom devise-like
constraints ->(req){ req.session[:user_id].present? && User.find_by(id: req.session[:user_id]) } do
  mount RailsI18nManager::Engine, at: "/rails_i18n_manager", as: "rails_i18n_manager"
end

### HTTP Basic Auth
with_http_basic_auth = ->(engine){
  Rack::Builder.new do
    use Rack::Auth::Basic do |username, password|
      ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(username), ::Digest::SHA256.hexdigest(ENV.fetch("RAILS_I18N_MANAGER_USERNAME"))) &&
        ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(password), ::Digest::SHA256.hexdigest(ENV.fetch("RAILS_I18N_MANAGER_PASSWORD")))
    end
    run(engine)
  end
}
mount with_http_basic_auth.call(RailsI18nManager::Engine), at: "/rails_i18n_manager", as: "rails_i18n_manager"

API Endpoint

We provide an endpoint to retrieve your translation files at /translations.

You will likely want to add your own custom authentication strategy and can do so using a routing constraint on the mount RailsI18nManager call.

From that point you can implement an automated mechanism to update your apps translations using the provided API end point. Some examples

An example in Ruby:

require 'open-uri'

zip_stream = URI.open('https://translations-manager.example.com/translations.zip?export_format=yaml')
IO.copy_stream(zip_stream, '/tmp/my-app-locales.zip')
`unzip /tmp/my-app-locales.zip /tmp/my-app-locales/`
`rsync --delete-after /tmp/my-app-locales/my-app/ /path/to/my-app/config/locales/`
puts "Locales are now updated, app restart not-required"

A command line example using curl:

curl https://translations-manager.example.com/translations.zip?export_format=json -o /tmp/my-app-locales.zip \
  && unzip /tmp/my-app-locales.zip /tmp/my-app-locales/ \
  && rsync --delete-after /tmp/my-app-locales/my-app/ \
  && echo "Locales are now updated, app restart not-required"

Development

Run migrations using: rails db:migrate

Run server using: bin/dev or cd test/dummy/; rails s

Testing

bundle exec rspec

We can locally test different versions of Rails using ENV['RAILS_VERSION']

export RAILS_VERSION=7.0
bundle install
bundle exec rspec

Other Translation Managers & Web Interfaces

For comparison, some other projects for managing Rails translations.

Credits

Created & Maintained by Weston Ganger - @westonganger

More Repositories

1

spreadsheet_architect

Spreadsheet Architect is a library that allows you to create XLSX, ODS, or CSV spreadsheets super easily from ActiveRecord relations, plain Ruby objects, or tabular data.
Ruby
1,298
star
2

paper_trail-association_tracking

Plugin for the PaperTrail gem to track and reify associations
Ruby
118
star
3

rearmed-js

A collection of helpful methods and monkey patches for Arrays, Objects, Numbers, and Strings in Javascript
JavaScript
104
star
4

active_snapshot

Simplified snapshots and restoration for ActiveRecord models and associations with a transparent white-box implementation
Ruby
96
star
5

rodf

ODF generation library for Ruby
Ruby
53
star
6

protected_attributes_continued

The community continued version of protected_attributes for Rails 5+
Ruby
45
star
7

rearmed-rb

A collection of helpful methods and monkey patches for Arrays, Hash, Enumerables, Strings, Objects & Dates in Ruby
Ruby
41
star
8

sexy_form.rb

Dead simple HTML form field builder for Ruby with built-in support for many popular UI libraries such as Bootstrap
Ruby
38
star
9

rearmed_rails

A collection of helpful methods and monkey patches for Rails
Ruby
33
star
10

form_builder.cr

Dead simple HTML form builder for Crystal with built-in support for many popular UI libraries such as Bootstrap
Crystal
31
star
11

bootstrap-directional-buttons

Directional / Arrow buttons for Bootstrap
HTML
22
star
12

capistrano-precompile-chooser

Capistrano plugin to precompile your Rails assets locally, remotely, or not at all provided with a very convenient default terminal prompt.
Ruby
13
star
13

active_sort_order

The "easy-peasy" dynamic sorting pattern for ActiveRecord that your Rails apps deserve
Ruby
13
star
14

input-autogrow

jQuery plugin for autogrowing inputs
JavaScript
8
star
15

chosen-bootstrap-theme

A Bootstrap theme for Chosen Select that actually looks like Bootstrap
CSS
8
star
16

js-try

JS-Try is a Javascript implementation of the try method from Rails for safe navigation
JavaScript
6
star
17

chosen-material-theme

A Material theme for Chosen Select
CSS
6
star
18

search_architect

Dead simple, powerful and fully customizable searching for your Rails or ActiveRecord models and associations.
Ruby
6
star
19

pairer

Pairer is Rails app/engine to Easily rotate and keep track of working pairs
Ruby
5
star
20

rails_uuid_to_integer_primary_keys

A Rails Migration to convert your UUID primary keys back to integer / bigint primary keys
Ruby
5
star
21

chosen-remote-source

Provides remote data source support for chosen-js selects
JavaScript
4
star
22

input-case-enforcer

Enforce uppercase, lowercase, or Capitalized inputs & textareas
JavaScript
4
star
23

paperclip_utils

Collection of Paperclip processors and a Helper class for easier dynamic processors and styles on your Paperclip uploads
Ruby
4
star
24

active_record_simple_execute

Sanitize and Execute your raw SQL queries in ActiveRecord and Rails with a much more intuitive and shortened syntax
Ruby
4
star
25

active_record_case_insensitive_finders

Adds case-insensitive finder methods to Rails and ActiveRecord
Ruby
3
star
26

chosen-readonly

Readonly support for Chosen selects
JavaScript
3
star
27

better_exception_notifier

An exception notifier for Rails and Rack apps
Ruby
3
star
28

rails_nestable_layouts

Rails Nestable Layouts - Dead simple nested layouts for Rails
Ruby
3
star
29

minitest_change_assertions

Provides assertions for your Minitest suite to determine if an object has been changed
Ruby
2
star
30

common_website_scripts_and_styles

JavaScript
2
star
31

rails_template

Efficient Rails Template
Ruby
2
star
32

rearmed-css

CSS Utility Classes
CSS
2
star
33

basic_ruby_and_rails_style_guide

2
star
34

devise_whos_here

Devise extension for logging current active users logged in using only the fast Rails cache and not your database
Ruby
2
star
35

simple_assets

Dead simple HTML-based assets helper for Ruby. The main idea here is to promote re-usability for projects.
Ruby
2
star
36

active_record_alias_join

Easily add custom SQL table aliases for your joins and includes
2
star
37

github_activity_scraper.rb

Scrape your entire GitHub activity information for all-time. Helps for aggregating how much open source sh!t you get done.
Ruby
2
star
38

accepts_nested_attributes_for_public_id

A patch for Rails to support using a public ID column instead of ID for use with accepts_nested_attributes_for
Ruby
2
star
39

rails_upgrade

Ruby
1
star
40

rubocop_template_for_productive_teams

Rubocop template designed speed up your teams development process instead of dragging it down
Ruby
1
star
41

github_actions_ci_example

Ruby
1
star
42

jekyll_template

CSS
1
star
43

ruby_view_template_converters

Complete solutions to convert ERB, SLIM, AND HAML with the least amount of manual effort
Ruby
1
star
44

westonganger

1
star
45

prawn_invoice

Dead simple Prawn based PDF invoice generator with support for custom invoice templates
Ruby
1
star
46

rails_dummy_app

Rails Dummy App and test_helper.rb for testing gems
Ruby
1
star
47

wagon_starter

Starter Template for LocomotiveCMS Wagon Sites
JavaScript
1
star
48

essential_capybara_helpers

A set of essential capybara helpers for everyday use
1
star
49

no_bullshit_middleman_template

Template for efficient static website generation using Middleman
HTML
1
star
50

fast_try

FastTry is a simple method wrapper to the safe navigation operator in Ruby
Ruby
1
star
51

lazy_serialize

Lazy Serialize is an alternative to ActiveRecord's serialize method which does not serialize each column until the first call to the attribute.
Ruby
1
star
52

prawn_resume

Dead simple Prawn based PDF resume generator with support for custom resume templates
Ruby
1
star
53

automatic_rails_route_testing

Template for easy exception testing for all routes within a Rails app
Ruby
1
star
54

select-sync

Javascript plugin for HTML `select` elements to synchronize by selected or disabled options
JavaScript
1
star
55

facebook_marketplace_scraper

A locally run Rails app to automatically search facebook marketplace for deals and aggregate them all in a list.
Ruby
1
star
56

rails_scrabble_with_friends

Simple web-based scrabble for you and your friends with zero friction authentication
Ruby
1
star
57

wagon_kitchen_sink

Example website for LocomotiveCMS / Wagon
JavaScript
1
star
58

rails_custom_form_builder

A good example/starter pack for a custom form builder for use with Rails form_for
Ruby
1
star
59

rails_clientside_javascript_error_handler

Easily handle client-side Javascript exceptions within your Rails app
Ruby
1
star