Permalink
Browse files

[fix] I18n: use string for I18.language and I18.region, to avoid some…

… overhead with big sum type

the big sum language type have generated a lot of scalability problems (and fixes)
and the benefit of the sum type was slight

it remains the problem of the executable size (contains both full client and server code)
  • Loading branch information...
OpaOnWindowsNow committed Sep 21, 2011
1 parent b51ff66 commit 1c08854681ba25370c73697e836a7adebb5a6e98
@@ -5,43 +5,43 @@ import stdlib.core.i18n
// "server"
// string, 6
__i18n_cf1e8c14e54505f60aa10ceb8d5d8ab3()= match I18n.lang()
-{fr} -> "serveur"
-{en} -> "server"
+"fr" -> "serveur"
+"en" -> "server"
_ -> "server"
// Template for hello_i18n.opa
// "{p1} say hello"
// string, 6
__i18n_51ceade11ee0ae73e2b41ed0feeafd1a(p1:string)= match I18n.lang()
-{fr} -> "{p1} dit bonjour"
-{en} -> "Hello from {p1}"
+"fr" -> "{p1} dit bonjour"
+"en" -> "Hello from {p1}"
_ -> "{p1} say hello"
// Template for hello_i18n.opa
// "client say _hello"
// string, 9
__i18n_7e3b0dc086f943b0c49c7a69f66f1cc1()= match I18n.lang()
-{fr} -> "bonjour (côté client)"
-{en} -> "hello (client side)"
+"fr" -> "bonjour (côté client)"
+"en" -> "hello (client side)"
_ -> "client say hello"
// Template for hello_i18n.opa
// "Hello World"
// string, 16
__i18n_b10a8db164e0754105b7a99be72e3fe5()= match I18n.lang()
-{fr} -> "Bonjour Monde"
-{en} -> "Good morning World"
+"fr" -> "Bonjour Monde"
+"en" -> "Good morning World"
_ -> "Hello World"
// Template for hello_i18n.opa
// "Hello"
// string, 19
__i18n_8b1a9953c4611296a827abf8c47804d7()= match I18n.lang()
-{fr} -> "Bonjour"
-{en} -> "Good morning"
+"fr" -> "Bonjour"
+"en" -> "Good morning"
_ -> "Hello"
@@ -144,7 +144,7 @@ debug(_) = void
ServerI18n =
{{
- default_lang = {en} : I18n.language
+ default_lang = "en" : I18n.language
get_system_lang() =
// OS specific

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -3,7 +3,8 @@
// DO NOT EDIT
/* This file contains the utility functions for all subtag described by iana.org language-subtag-registry */
-type I18n.region =
+type I18n.region = string
+/*
/ {`AC`} // Ascension
/ {`AD`} // Andorra
/ {`AE`} // United
@@ -301,17 +302,17 @@ type I18n.region =
/ {`154`} // Northern
/ {`155`} // Western
/ {`419`} // Latin
-
+*/
I18n_region = {{
-parse(s) : option(I18n.region) =
+@server parse(s) : option(I18n.region) =
check(s) = match s
"AC""AD""AE""AF""AG""AI""AL""AM""AN""AO""AQ""AR""AS""AT""AU""AW""AX""AZ""BA""BB""BD""BE""BF""BG""BH""BI""BJ""BL""BM""BN""BO""BQ""BR""BS""BT""BU""BV""BW""BY""BZ""CA""CC""CD""CF""CG""CH""CI""CK""CL""CM""CN""CO""CP""CR""CS""CU""CV""CW""CX""CY""CZ""DD""DE""DG""DJ""DK""DM""DO""DZ""EA""EC""EE""EG""EH""ER""ES""ET""EU""FI""FJ""FK""FM""FO""FR""FX""GA""GB""GD""GE""GF""GG""GH""GI""GL""GM""GN""GP""GQ""GR""GS""GT""GU""GW""GY""HK""HM""HN""HR""HT""HU""IC""ID""IE""IL""IM""IN""IO""IQ""IR""IS""IT""JE""JM""JO""JP""KE""KG""KH""KI""KM""KN""KP""KR""KW""KY""KZ""LA""LB""LC""LI""LK""LR""LS""LT""LU""LV""LY""MA""MC""MD""ME""MF""MG""MH""MK""ML""MM""MN""MO""MP""MQ""MR""MS""MT""MU""MV""MW""MX""MY""MZ""NA""NC""NE""NF""NG""NI""NL""NO""NP""NR""NT""NU""NZ""OM""PA""PE""PF""PG""PH""PK""PL""PM""PN""PR""PS""PT""PW""PY""QA""RE""RO""RS""RU""RW""SA""SB""SC""SD""SE""SG""SH""SI""SJ""SK""SL""SM""SN""SO""SR""SS""ST""SU""SV""SX""SY""SZ""TA""TC""TD""TF""TG""TH""TJ""TK""TL""TM""TN""TO""TP""TR""TT""TV""TW""TZ""UA""UG""UM""US""UY""UZ""VA""VC""VE""VG""VI""VN""VU""WF""WS""YD""YE""YT""YU""ZA""ZM""ZR""ZW""001""002""003""005""009""011""013""014""015""017""018""019""021""029""030""034""035""039""053""054""057""061""142""143""145""150""151""154""155""419"
-> true
_ -> false
end
- if check(s) then some(OpaValue.Record.make_simple_record(OpaValue.Record.field_of_name_unsafe(s))) else none
+ if check(s) then some(s/*OpaValue.Record.make_simple_record(OpaValue.Record.field_of_name_unsafe(s))*/) else none
-to_string(k:I18n.region) = OpaValue.Record.get_uniq_field_name(k) ? error("I18n.region.to_string")
+to_string(k:I18n.region) = k //OpaValue.Record.get_uniq_field_name(k) ? error("I18n.region.to_string")
}}

0 comments on commit 1c08854

Please sign in to comment.