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

The action factory

Synchronisation of a translation files

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

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.