Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/richardvenneman/trestle-mobility
🌐 Mobility integration plugin for the Trestle admin framework
https://github.com/richardvenneman/trestle-mobility
admin i18n mobility rails ruby trestle
Last synced: 2 months ago
JSON representation
🌐 Mobility integration plugin for the Trestle admin framework
- Host: GitHub
- URL: https://github.com/richardvenneman/trestle-mobility
- Owner: richardvenneman
- License: mit
- Created: 2019-04-08T10:05:36.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-03-16T12:55:39.000Z (almost 3 years ago)
- Last Synced: 2024-11-16T02:52:57.974Z (3 months ago)
- Topics: admin, i18n, mobility, rails, ruby, trestle
- Language: Ruby
- Size: 168 KB
- Stars: 9
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Trestle Mobility Integration (trestle-mobility)
> [Mobility](https://github.com/shioyama/mobility) integration plugin for the [Trestle admin framework](https://trestle.io)
[![Gem](https://img.shields.io/gem/v/trestle-mobility.svg)](https://rubygems.org/gems/trestle-mobility)
## Features / problems
- Manage Mobility translations with a space-efficient dropdown interface in Trestle
- Supports text fields, text area's and check boxes
- Integrates with [DeepL Pro](https://www.deepl.com/pro.html) to automatically translate fields
## Getting started
These instructions assume you have a working Trestle application. To integrate trestle-mobility, first add it to your application's Gemfile:
```ruby
gem 'trestle-mobility'
```Run `bundle install`, and then run the install generator to set up configuration options.
$ rails generate trestle:mobility:install
## Usage
Trestle Mobility requires you to enable [Mobility's `locale_accessors` plugin](https://github.com/shioyama/mobility#getset).
Assuming you've setup your models with Mobility's `translates` directives, you can use the `mobility_text_field`, `mobility_text_area` and `mobility_check_box` field types:
```ruby
Trestle.resource(:posts) do
form do |post|
mobility_text_field :title
mobility_text_field :subtitle
mobility_text_area :content
mobility_check_box :published
end
end
```Trestle Mobility allows you to specify the language that is selected by default:
```ruby
mobility_text_field :subtitle, selected: "nl"
```By default Trestle Mobility uses `I18n.available_locales` to generate the form fields, but you can specify the languages on a per-field basis:
```ruby
mobility_text_field :title, locales: %w(nl de fr)
```Quoting Mobility's README:
> (Note however that Mobility will complain if you have I18n.enforce_available_locales set to true and you try accessing a locale not present in I18n.available_locales; set it to false if you want to allow any locale.)
## DeepL translation
Trestle Mobility can automatically populate empty field values with translations from other languages. This functionality is powered by the excellent [deepl-rb](https://github.com/wikiti/deepl-rb) gem. To make use of this, add `deepl-rb` to your Gemfile and specify your DeepL Pro API key in your Trestle initializer:
```ruby
config.mobility.deepl_api_key = "YOUR-API-KEY"
```It is possible to pass any DeepL API options to the field (check out the [deepl-rb documentation](https://github.com/wikiti/deepl-rb#translate) section on params):
```ruby
mobility_text_area :content, rows: 14, deepl_query_params: { tag_handling: "xml" }
```