Skip to content

Commit

Permalink
Add Swedish locale + test.
Browse files Browse the repository at this point in the history
  • Loading branch information
futhr committed Mar 12, 2014
1 parent 5ef933b commit 74a65bf
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 3 deletions.
2 changes: 1 addition & 1 deletion MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2008-2012 Lucky Sneaks
Copyright (c) 2008-2014 Lucky Sneaks

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
5 changes: 3 additions & 2 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Unlike other permalink solutions, ActsAsUrl doesn't rely on Iconv (which is inco
"$12 worth of Ruby power".to_url => "12-dollars-worth-of-ruby-power"
"10% off if you act now".to_url => "10-percent-off-if-you-act-now"

# You don't even wanna trust Iconv for this next part
# You should never rely on Iconv for this next part
"kick it en Français".to_url => "kick-it-en-francais"
"rock it Español style".to_url => "rock-it-espanol-style"
"tell your readers 你好".to_url => "tell-your-readers-ni-hao"
Expand Down Expand Up @@ -113,6 +113,7 @@ Currently, built-in translations are available for the following languages:

* English (en)
* Danish (da)
* Swedish (sv)
* Dutch (nl)
* German (de)
* Portuguese Brazilian (pt-BR)
Expand All @@ -137,4 +138,4 @@ If it's not obvious, some of the code for ActsAsUrl is based on Rick Olsen's per

GIANT thanks to the many contributors who have helped make Stringex better and better: http://github.com/rsl/stringex/contributors

copyright (c) 2008-2013 Lucky Sneaks, released under the MIT license
copyright (c) 2008-2014 Lucky Sneaks, released under the MIT license
76 changes: 76 additions & 0 deletions locales/sv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# NOTE: Some translation keys make use of matches from regular expressions
# to manipulate whitespace and order. Please consult the source code for
# Stringex::Localization::ConversionExpressions to see what those
# regular expressions look like if you need to manipulate the order
# differently than the usage below.
sv:
stringex:
characters:
and: och
at: snabel-a
divide: delat med
degrees: grader
dot: \1 punkt \2
ellipsis: punkt punkt punkt
equals: lika med
number: nummer
percent: procent
plus: plus
slash: slash
star: stjärna
currencies:
generic: \1 kronor
dollars: \1 dollar
dollars_cents: \1 dollar \2 cent
pounds: \1 pund
pounds_pence: \1 pund \2 pence
euros: \1 euro
euros_cents: \1 euro \2 cent
yen: \1 yen
reais: \1 reais
reais_cents: \1 reais \2 cent
html_entities:
amp: och
cent: " cents"
copy: (c)
deg: " grader "
divide: " delat med "
double_quote: '"'
ellipsis: "..."
en_dash: "-"
em_dash: "--"
frac14: en fjärdedel
frac12: halv
frac34: tre fjärdedelar
gt: ">"
lt: <
nbsp: " "
pound: " pund "
reg: (r)
single_quote: "'"
times: x
trade: (tm)
yen: " yen "
vulgar_fractions:
half: halv
one_third: en tredjedel
two_thirds: två tredjedelar
one_fourth: en fjärdedel
three_fourths: tre fjärdedelar
one_fifth: en femtedel
two_fifths: två femtedelar
three_fifths: tre femtedelar
four_fifths: fyra femtedelar
one_sixth: en sjättedel
five_sixths: fem sjättedelar
one_eighth: en åttondel
three_eighths: tre åttondelar
five_eighths: fem åttondelar
seven_eighths: sju åttondelar
transliterations:
Å: A
Ä: AE
Ö: OE
å: a
ä: ae
ö: oe
118 changes: 118 additions & 0 deletions test/unit/localization/sv_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# encoding: UTF-8

require 'test_helper'
require 'i18n'
require 'stringex'

class SwedishYAMLLocalizationTest < Test::Unit::TestCase
def setup
Stringex::Localization.reset!
Stringex::Localization.backend = :i18n
Stringex::Localization.backend.load_translations :sv
Stringex::Localization.locale = :sv
end

{
"foo & bar" => "foo och bar",
"AT&T" => "AT och T",
"99° is normal" => "99 grader is normal",
"4 ÷ 2 is 2" => "4 delat med 2 is 2",
"webcrawler.com" => "webcrawler punkt com",
"Well..." => "Well punkt punkt punkt",
"x=1" => "x lika med 1",
"a #2 pencil" => "a nummer 2 pencil",
"100%" => "100 procent",
"cost+tax" => "cost plus tax",
"batman/robin fan fiction" => "batman slash robin fan fiction",
"dial *69" => "dial stjärna 69"
# " i leave whitespace on ends unchanged " => " i leave whitespace on ends unchanged "
}.each do |original, converted|
define_method "test_character_conversion: '#{original}'" do
assert_equal converted, original.convert_miscellaneous_characters
end
end

{
"¤20" => "20 kronor",
"$100" => "100 dollar",
"$19.99" => "19 dollar 99 cent",
"£100" => "100 pund",
"£19.99" => "19 pund 99 pence",
"€100" => "100 euro",
"€19.99" => "19 euro 99 cent",
"¥1000" => "1000 yen"
}.each do |original, converted|
define_method "test_currency_conversion: '#{original}'" do
assert_equal converted, original.convert_miscellaneous_characters
end
end

{
"Tea &amp; Sympathy" => "Tea och Sympathy",
"10&cent;" => "10 cents",
"&copy;2000" => "(c)2000",
"98&deg; is fine" => "98 grader is fine",
"10&divide;5" => "10 delat med 5",
"&quot;quoted&quot;" => '"quoted"',
"to be continued&hellip;" => "to be continued...",
"2000&ndash;2004" => "2000-2004",
"I wish&mdash;oh, never mind" => "I wish--oh, never mind",
"&frac12; ounce of gold" => "halv ounce of gold",
"1 and &frac14; ounces of silver" => "1 and en fjärdedel ounces of silver",
"9 and &frac34; ounces of platinum" => "9 and tre fjärdedelar ounces of platinum",
"3&gt;2" => "3>2",
"2&lt;3" => "2<3",
"two&nbsp;words" => "two words",
"&pound;100" => "pund 100",
"Walmart&reg;" => "Walmart(r)",
"&apos;single quoted&apos;" => "'single quoted'",
"2&times;4" => "2x4",
"Programming&trade;" => "Programming(tm)",
"&yen;20000" => "yen 20000",
" i leave whitespace on ends unchanged " => " i leave whitespace on ends unchanged "
}.each do |original, converted|
define_method "test_html_entity_conversion: '#{original}'" do
assert_equal converted, original.convert_miscellaneous_html_entities
end
end

{
"&frac12;" => "halv",
"½" => "halv",
"&#189;" => "halv",
"⅓" => "en tredjedel",
"&#8531;" => "en tredjedel",
"⅔" => "två tredjedelar",
"&#8532;" => "två tredjedelar",
"&frac14;" => "en fjärdedel",
"¼" => "en fjärdedel",
"&#188;" => "en fjärdedel",
"&frac34;" => "tre fjärdedelar",
"¾" => "tre fjärdedelar",
"&#190;" => "tre fjärdedelar",
"⅕" => "en femtedel",
"&#8533;" => "en femtedel",
"⅖" => "två femtedelar",
"&#8534;" => "två femtedelar",
"⅗" => "tre femtedelar",
"&#8535;" => "tre femtedelar",
"⅘" => "fyra femtedelar",
"&#8536;" => "fyra femtedelar",
"⅙" => "en sjättedel",
"&#8537;" => "en sjättedel",
"⅚" => "fem sjättedelar",
"&#8538;" => "fem sjättedelar",
"⅛" => "en åttondel",
"&#8539;" => "en åttondel",
"⅜" => "tre åttondelar",
"&#8540;" => "tre åttondelar",
"⅝" => "fem åttondelar",
"&#8541;" => "fem åttondelar",
"⅞" => "sju åttondelar",
"&#8542;" => "sju åttondelar"
}.each do |original, converted|
define_method "test_vulgar_fractions_conversion: #{original}" do
assert_equal converted, original.convert_vulgar_fractions
end
end
end

0 comments on commit 74a65bf

Please sign in to comment.