Last active
May 1, 2019 15:18
-
-
Save dabit/f4b43f5abc9b2e8042832437173b1a4c to your computer and use it in GitHub Desktop.
translations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I18n.t('welcome', scope: 'pages.title.welcome') | |
I18n.t('pages.title.welcome') | |
I18n.t('activerecord.model.dog') # => "Bienvenido" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Welcome to RailsConf</h1> | |
<p>I hope you enjoy my talk</p> | |
<h1><%= t('pages.welcome.title') %></h1> | |
<p><%= t('pages.welcome.body') %></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
es: | |
pages: | |
title: | |
welcome: "Bienvenido" | |
es: | |
pages: | |
welcome: | |
title: "Bienvenidos a RailsConf" | |
body: "Espero que disfrutes mi charla" | |
en: | |
pages: | |
welcome: | |
title: "Welcome to RailsConf" | |
body: "I hope you enjoy my talk" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Habitacion ; end | |
class HabitacionesController ; end | |
class Reservacion ; end | |
class ReservacionesController ; end | |
class Room ; end | |
class RoomsController ; end | |
class Reservation ; end | |
class ReservactionsController ; end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/application.rb | |
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'i18n-debug', group: :development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
es: | |
attributes: | |
name: Nombre |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
es: | |
activerecord: | |
attributes: | |
author: | |
name: Nombre de pila |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>New Author</h1> | |
<%= render 'form', author: @author %> | |
<%= link_to 'Back', authors_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1><%= t('.page_title') %></h1> | |
<%= render 'form', author: @author %> | |
<%= link_to 'Back', authors_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1><%= I18n.t('.page_title') %></h1> | |
<%= render 'form', author: @author %> | |
<%= link_to 'Back', authors_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1><%= t('.page_title') %></h1> | |
<h2><%= t('.title1') %></h2> | |
<p><%= t('.paragraph1') %></p> | |
<h2><%= t('.title2') %></h2> | |
<p><%= t('.paragraph2') %></p> | |
<h2><%= t('.title3') %></h2> | |
<p><%= t('.paragraph3') %></p> | |
<h2><%= t('.title4') %></h2> | |
<p><%= t('.paragraph4') %></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="field"> | |
<%= f.label :name %> | |
<%= f.text_field :name %> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# POST /authors | |
def create | |
@author = Author.new(author_params) | |
respond_to do |format| | |
if @author.save | |
format.html { redirect_to @author, notice: I18n.t('.flash') } | |
else | |
format.html { render :new } | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# POST /authors | |
def create | |
@author = Author.new(author_params) | |
respond_to do |format| | |
if @author.save | |
format.html { redirect_to @author, notice: 'Author was successfully created.' } | |
else | |
format.html { render :new } | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Railsconf | |
class Application < Rails::Application | |
config.i18n.fallbacks = { en_GB: [ :en ] } | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
en: | |
fallbacks: | |
show: | |
soccer: Soccer | |
football: Football | |
restroom: Restroom | |
bill: Bill | |
shower: Shower | |
words: WORDS | |
in: IN | |
common: COMMON |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
en_GB: | |
fallbacks: | |
show: | |
soccer: Football | |
football: American Football | |
restroom: Toilet | |
bill: Note | |
shower: Bath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Author < ApplicationRecord | |
enum category: %i(classic independent mistery fiction) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def new | |
@author = Author.new | |
@categories = Author.categories | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def new | |
@author = Author.new | |
@categories = Author.categories.map {|c,i| [t(c), i]} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'i18n-active_record', :require => 'i18n/active_record' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateTranslations < ActiveRecord::Migration | |
def self.up | |
create_table :translations do |t| | |
t.string :locale | |
t.string :key | |
t.text :value | |
t.text :interpolations | |
t.boolean :is_proc, :default => false | |
t.timestamps | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/translations.rb | |
I18n.backend = x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'i18n/backend/active_record' | |
I18n.backend = I18n::Backend::ActiveRecord.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Translation = I18n::Backend::ActiveRecord::Translation | |
Translation.create locale: :es, key: 'authors.new.page_title', value: 'Autor Nuevo' | |
Translation.create locale: :es, key: 'helpers.label.author.name', value: 'Nombre de autor' | |
Translation.create locale: :es, key: 'attributes.bio', value: 'Biografía' | |
Translation.create locale: :es, key: 'attributes.age', value: 'Edad' | |
Translation.create locale: :es, key: 'attributes.category', value: 'Categoría' | |
Translation.create locale: :es, key: 'helpers.submit.create', value: 'Crear %{model}' | |
Translation.create locale: :es, key: 'classic', value: 'Clásico' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'i18n/backend/hodor' | |
I18n.backend = I18n::Backend::Hodor.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'i18n/backend/base' | |
class I18n::Backend::Hodor | |
include I18n::Backend::Base | |
def lookup(locale, key, scope = [], options = {}) | |
"Hodor" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I18n::Backend::Simple | |
I18n::Backend::ActiveRecord | |
I18n::Backend::Redis | |
I18n::Backend::Mongodb | |
I18n::Backend::Gettext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I18n::Backend::Chain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'i18n/backend/active_record' | |
I18n.backend = I18n::Backend::Chain.new( I18n::Backend::ActiveRecord.new, I18n.backend ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
en: | |
time: | |
formats: | |
default: "%H:%M" | |
formal: "The time is now %H:%M good sir" | |
informal: "The time is %H, bye" | |
thing: "Clobberin time" | |
rock: "It doesn't matter what time it is" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
distance_of_time_in_words_to_now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment