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
960
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
260
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
280
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.3k
Other Decks in Programming
See All in Programming
GitHubで育つ コラボレーション文化 : ニフティでのインナーソース挑戦事例 - 2024-12-16 GitHub Universe 2024 Recap in ZOZO
niftycorp
PRO
0
1.1k
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
230
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
630
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
8
1.8k
Zoneless Testing
rainerhahnekamp
0
150
EC2からECSへ 念願のコンテナ移行と巨大レガシーPHPアプリケーションの再構築
sumiyae
3
540
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
130
MCP with Cloudflare Workers
yusukebe
2
270
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
390
Package Traits
ikesyo
1
150
HTML/CSS超絶浅い説明
yuki0329
0
160
Jaspr Dart Web Framework 박제창 @Devfest 2024
itsmedreamwalker
0
140
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Visualization
eitanlees
146
15k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.4k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Building Your Own Lightsaber
phodgson
104
6.2k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.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!