Git Product home page Git Product logo

tt's Introduction

Dos-T

Build Status Gem Version

Dos-T introduces a translation convention for a ruby web application (with a focus on the rails flow). The library is based on the next ideas:

  • focus on a every day issues
  • reduce amount of duplications inside translation files
  • easy to use from day one & minimum to write (nobody likes to write a long and obvious method names)
  • have a clear defaults

Usage

Dos-T adds an extra helper method tt into your controllers, mailers & views. The best way to explain all features is to look at Cheatsheet. The below is shown a brief overview:

# en:
#   actions:
#     base:
#       add: "Add a new %{r}"
#   attributes:
#     user:
#       name: "Name"
#       email: "Email"
#       role: "Role"
#   common:
#     actions: "Actions"
#     confirm: "Are you sure?"
#     edit: "Edit"
#     delete: "Delete"
#   enums:
#     user:
#       role:
#         a: "Admin"
#         g: "Guest"
#         m: "Manager"
#   models:
#     user:
#       one: "User"
#       other: "Users"

# app/views/users/index.haml
%h2= tt.rs :user

%table
  %thead
    %th= tt.attr :name
    %th= tt.attr :email
    %th= tt.attr :role
    %th= tt.c :actions

  %tbody
    - @users.each do |user|
      %tr
        %td= user.name
        %td= user.email
        %td= tt.enum :role, user.role
        %td
          = link_to tt.c(:edit), edit_user_path(user)
          = link_to tt.c(:delete), user_path(user), method: :delete, confirm: tt.c(:confirm)

= link_to tt.a(:add), new_user_path

The result will be the next:

%h2 Users

%table
  %thead
    %th Name
    %th Email
    %th Role
    %th Actions

  %tbody
    - @users.each do |user|
      %tr
        %td= user.name
        %td= user.email
        %td= { 'a' => 'Admin', 'g' => 'Guest', 'm' => 'Manager' }[user.role]
        %td
          = link_to 'Edit', edit_user_path(user)
          = link_to 'Delete', user_path(user), method: :delete, confirm: 'Are you sure?'

= link_to 'Add a new user', new_user_path

Additional features

Setup

Just add gem "t_t" into your Gemfile and run bundle.

Requirements

Dos-T is tested against Ruby 1.9.3+ & JRuby(1.9+ compatible). If your application uses Ruby on Rails the framework version should be 3.2+

Changelog

  • 1.3.1
    • Add csv export in tt:m task
  • 1.3.0
    • Allow specify a custom mark for locale file synchonization
  • 1.2.2
    • Fix rails 5 integration
  • 1.2.0
  • 1.1.0:
    • Added the action factory
    • Improve #attr, #r, #rs methods to make them more compatible with ActiveModel methods
    • Fix a documentation mismatching
  • 1.0.1
    • fix the activerecord integration

tt's People

Contributors

jalkoby avatar

Stargazers

 avatar Felix  avatar Robert Audi avatar Ashar avatar Michael Chrisco avatar David Montesdeoca avatar Hendrik Gebhardt avatar Aike de Jongste avatar Alex Tonkonozhenko avatar Ricardo Pontes avatar Vitor Talaia avatar Chris Lusted avatar Christian Hardacre avatar Jan Strnádek avatar Carl Leen avatar Vladimir Vinnikov avatar Jeroen Jacobs avatar Mohamad Abras avatar Josh Powell avatar Chris Edwards avatar Fon avatar Flávio M. Oota avatar Roland Koch avatar Vitauts Stočka avatar Victor Asteinza avatar Szymon Czarnecki avatar Anton Maminov avatar Gabriel Francisco avatar Angus H. avatar Vova avatar Delmaire Loïc avatar Amrendra Singh avatar QUANON avatar  avatar  avatar Andrew Volozhanin avatar Amit Erandole avatar wyefei avatar Leandro Pedroni avatar Luis Mayoral avatar Kelvin Stinghen avatar Igor Victor avatar Kent avatar Aleksey Demidov avatar Denis Denisov avatar Jonas avatar AlexDenisov avatar Stefan Wienert avatar  avatar

Watchers

 avatar James Cloos avatar Amrendra Singh avatar  avatar

Forkers

iq-scm

tt's Issues

undefined method `helper_method' for ActionController::API

Hi,

i am in process of upgrading Rails from 5.0.2 to 5.1 (currently on 5.0.3), but i am having problems with t_t as described in the title. Actually, I also upgraded Draper from 3.0.0-pre1 to 3.0.0.

If i leave Draper on pre-release, then everything is fine, if i go to stable release, t_t breaks.

Error:
.../gems/t_t-1.2.1/lib/t_t/rails.rb:20:in 'block in <module:Helper>': undefined method 'helper_method' for ActionController::API:Class (NoMethodError)

Is there any chance you could fix this? Thx

There was an error while trying to load the gem 't_t'. (Bundler::GemRequireError)

Hi,

i would really like to get hands on your gem which looks quite useful, but can't load it somehow.
I am getting a mentioned error. This is a bit more:

There was an error while trying to load the gem 't_t'. (Bundler::GemRequireError)
/home/XXX/.rvm/gems/ruby-2.2.2@informator/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in rescue in block (2 levels) in require' /home/XXX/.rvm/gems/ruby-2.2.2@informator/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:inblock (2 levels) in require'
/home/XXX/.rvm/gems/ruby-2.2.2@informator/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in each' /home/XXX/.rvm/gems/ruby-2.2.2@informator/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:inblock in require'
/home/XXX/.rvm/gems/ruby-2.2.2@informator/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in each' /home/XXX/.rvm/gems/ruby-2.2.2@informator/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:inrequire'
/home/XXX/.rvm/gems/ruby-2.2.2@informator/gems/bundler-1.11.2/lib/bundler.rb:99:in require' /home/XXX/projects/development/informator/config/application.rb:7:in<top (required)>'
/home/XXX/projects/development/informator/config/environment.rb:2:in require' /home/XXX/projects/development/informator/config/environment.rb:2:in<top (required)>'
config.ru:3:in require' config.ru:3:inblock in

'
/home/XXX/.rvm/gems/ruby-2.2.2@informator/gems/rack-1.6.4/lib/rack/builder.rb:55:in instance_eval' /home/XXX/.rvm/gems/ruby-2.2.2@informator/gems/rack-1.6.4/lib/rack/builder.rb:55:ininitialize'
config.ru:1:in new' config.ru:1:in'
/home/XXX/.rvm/gems/ruby-2.1.2/gems/passenger-5.0.10/helper-scripts/rack-preloader.rb:107:in eval' /home/XXX/.rvm/gems/ruby-2.1.2/gems/passenger-5.0.10/helper-scripts/rack-preloader.rb:107:inpreload_app'
/home/XXX/.rvm/gems/ruby-2.1.2/gems/passenger-5.0.10/helper-scripts/rack-preloader.rb:153:in <module:App>' /home/XXX/.rvm/gems/ruby-2.1.2/gems/passenger-5.0.10/helper-scripts/rack-preloader.rb:29:inmodule:PhusionPassenger'
/home/XXX/.rvm/gems/ruby-2.1.2/gems/passenger-5.0.10/helper-scripts/rack-preloader.rb:28:in `'

Using t_t in models

Hi,
is there a way to use TT in models? (ex. for validation message purposes)

Thank you!

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.