Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
I18n Alchemy
Search
Plataformatec
August 30, 2012
Programming
1
25k
I18n Alchemy
Lightning Talk por Lucas Mazza, na RubyConf Brasil 2012.
Plataformatec
August 30, 2012
Tweet
Share
More Decks by Plataformatec
See All by Plataformatec
O case da Plataformatec com o Elixir - Como uma empresa brasileira criou uma linguagem que é usada no mundo inteiro @ Elixir Brasil 2019
plataformatec
5
910
O case da Plataformatec com o Elixir - Como uma empresa brasileira criou uma linguagem que é usada no mundo inteiro @ QCon SP 2018
plataformatec
1
220
Elixir @ iMasters Intercon 2016
plataformatec
1
250
GenStage and Flow by @josevalim at ElixirConf
plataformatec
17
2.7k
Elixir: Programação Funcional e Pragmática @ 2º Tech Day Curitiba
plataformatec
2
290
Elixir: Programação Funcional e Pragmática @ Encontro Locaweb 2016
plataformatec
4
270
What's ahead for Elixir: v1.2 and GenRouter
plataformatec
15
2k
Arquiteturas Comuns de Apps Rails @ RubyConf BR 2015
plataformatec
6
370
Pirâmide de testes, escrevendo testes com qualidade @ RubyConf 2015
plataformatec
10
2.2k
Other Decks in Programming
See All in Programming
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
280
Jakarta EE meets AI
ivargrimstad
0
130
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
みんなでプロポーザルを書いてみた
yuriko1211
0
260
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
Outline View in SwiftUI
1024jp
1
330
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
330
Quine, Polyglot, 良いコード
qnighy
4
640
CSC509 Lecture 12
javiergs
PRO
0
160
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.1k
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
Featured
See All Featured
Building Applications with DynamoDB
mza
90
6.1k
Why Our Code Smells
bkeepers
PRO
334
57k
Rails Girls Zürich Keynote
gr2m
94
13k
Done Done
chrislema
181
16k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
For a Future-Friendly Web
brad_frost
175
9.4k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Automating Front-end Workflow
addyosmani
1366
200k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Faster Mobile Websites
deanohume
305
30k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Transcript
I18nAlchemy
@lucasmazza
None
datas, números e valores • DD/MM/YYYY ➜ MM/DD/YYYY • 1.5
➜ 1.50 • 1,000.00 ➜ 1000.00
Rails + i18n l(@event.starts_at, :format => :short) # '30 de
Agosto' number_with_precision(1200.3) # '1,200.30'
@event.starts_at = '30/08/2012' @event.starts_at # nil
lol no @event.starts_at = '30/08/2012' @event.starts_at # nil
gem install i18n-alchemy
@cantoniodasilva
@cantoniodasilva señor developer @ plataformatec
@cantoniodasilva señor developer @ plataformatec “ENTENDENDO E TIRANDO O MELHOR
DO RAILS ACTIVE MODEL” 11h @ Sala 2
class Event < ActiveRecord::Base include I18n::Alchemy localize :starts_at, :ends_at, :price
end I18nAlchemy
class Event < ActiveRecord::Base include I18n::Alchemy localize :starts_at, :ends_at, :price
end I18nAlchemy
I18n.with_locale :pt do @event.localized.starts_at = '30/08/2012' @event.starts_at # => Date.new(2012,
08, 30) @event.localized.starts_at # => '30/08/2012' @event.localized.price = '150,00' @event.localized.starts_at = 3.days.ago @event.save! end I18nAlchemy
.localized?
.localized? • I18n::Alchemy::Proxy
.localized? • I18n::Alchemy::Proxy • Nada de sobreescrever acessores
.localized? • I18n::Alchemy::Proxy • Nada de sobreescrever acessores • Manipula
apenas os atributos configurados
I18nAlchemy class Product < ActiveRecord::Base include I18n::Alchemy localize :total, :using
=> :number def total quantity * price end end
I18nAlchemy • Configurações através do i18n • Não é dependente
do ActiveRecord • Escreva os seus próprios parsers!
module MyParser def self.parse(value) # ... end def self.localize(value) #
... end end class Product < ActiveRecord::Base include I18n::Alchemy localize :total, :using => MyParser end
Para pull requests, issues, declarações de amor e afins: https://github.com/carlosantoniodasilva/i18n_alchemy
Obrigado!