Code Monkey home page Code Monkey logo

trestle-mobility's Introduction

Trestle Mobility Integration (trestle-mobility)

Mobility integration plugin for the Trestle admin framework

Gem

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 to automatically translate fields

Trestle Mobility screenshot

Getting started

These instructions assume you have a working Trestle application. To integrate trestle-mobility, first add it to your application's Gemfile:

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.

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:

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:

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:

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 DeepL integration screenshot

Trestle Mobility can automatically populate empty field values with translations from other languages. This functionality is powered by the excellent 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:

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 section on params):

mobility_text_area :content, rows: 14, deepl_query_params: { tag_handling: "xml" }

trestle-mobility's People

Contributors

asad-ali-bhatti avatar mcripper avatar richardvenneman avatar stestaub avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.