https://github.com/jalkoby/tt
Dos-T – an opinionated I18n helper(for those who don't want to waste time on translation)
https://github.com/jalkoby/tt
Last synced: over 1 year ago
JSON representation
Dos-T – an opinionated I18n helper(for those who don't want to waste time on translation)
- Host: GitHub
- URL: https://github.com/jalkoby/tt
- Owner: jalkoby
- Created: 2015-01-25T03:06:04.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-08-30T11:40:21.000Z (almost 2 years ago)
- Last Synced: 2025-02-28T19:53:13.649Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 60.5 KB
- Stars: 49
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Dos-T
[](https://travis-ci.org/jalkoby/tt)
[](https://badge.fury.io/rb/t_t)
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](./cheatsheet.md). The below is shown a brief overview:
```Haml
# 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:
```Haml
%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](./docs/action_factory.md)
#### [Synchronisation of a translation files](./docs/synchronisation.md)
## 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
- Deprecate TT::Translator in favour of TT::Base & TT::Rails
- Introduce a real-time watcher for [translation file synchronisation](./docs/synchronisation.md)
- 1.1.0:
- Added [the action factory](./docs/action_factory.md)
- Improve #attr, #r, #rs methods to make them more compatible with ActiveModel methods
- Fix a documentation mismatching
- 1.0.1
- fix the activerecord integration