Skip to content

Commit

Permalink
[fix] I18n: use string for I18.language and I18.region, to avoid some…
Browse files Browse the repository at this point in the history
… 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 1c08854
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
20 changes: 10 additions & 10 deletions doc/i18n/example/translation/hello_i18n.translation.opa
Expand Up @@ -5,43 +5,43 @@ import stdlib.core.i18n
// "server" // "server"
// string, 6 // string, 6
__i18n_cf1e8c14e54505f60aa10ceb8d5d8ab3()= match I18n.lang() __i18n_cf1e8c14e54505f60aa10ceb8d5d8ab3()= match I18n.lang()
{fr} -> "serveur" "fr" -> "serveur"
{en} -> "server" "en" -> "server"
_ -> "server" _ -> "server"




// Template for hello_i18n.opa // Template for hello_i18n.opa
// "{p1} say hello" // "{p1} say hello"
// string, 6 // string, 6
__i18n_51ceade11ee0ae73e2b41ed0feeafd1a(p1:string)= match I18n.lang() __i18n_51ceade11ee0ae73e2b41ed0feeafd1a(p1:string)= match I18n.lang()
{fr} -> "{p1} dit bonjour" "fr" -> "{p1} dit bonjour"
{en} -> "Hello from {p1}" "en" -> "Hello from {p1}"
_ -> "{p1} say hello" _ -> "{p1} say hello"




// Template for hello_i18n.opa // Template for hello_i18n.opa
// "client say _hello" // "client say _hello"
// string, 9 // string, 9
__i18n_7e3b0dc086f943b0c49c7a69f66f1cc1()= match I18n.lang() __i18n_7e3b0dc086f943b0c49c7a69f66f1cc1()= match I18n.lang()
{fr} -> "bonjour (côté client)" "fr" -> "bonjour (côté client)"
{en} -> "hello (client side)" "en" -> "hello (client side)"
_ -> "client say hello" _ -> "client say hello"




// Template for hello_i18n.opa // Template for hello_i18n.opa
// "Hello World" // "Hello World"
// string, 16 // string, 16
__i18n_b10a8db164e0754105b7a99be72e3fe5()= match I18n.lang() __i18n_b10a8db164e0754105b7a99be72e3fe5()= match I18n.lang()
{fr} -> "Bonjour Monde" "fr" -> "Bonjour Monde"
{en} -> "Good morning World" "en" -> "Good morning World"
_ -> "Hello World" _ -> "Hello World"




// Template for hello_i18n.opa // Template for hello_i18n.opa
// "Hello" // "Hello"
// string, 19 // string, 19
__i18n_8b1a9953c4611296a827abf8c47804d7()= match I18n.lang() __i18n_8b1a9953c4611296a827abf8c47804d7()= match I18n.lang()
{fr} -> "Bonjour" "fr" -> "Bonjour"
{en} -> "Good morning" "en" -> "Good morning"
_ -> "Hello" _ -> "Hello"


2 changes: 1 addition & 1 deletion stdlib/core/i18n/i18n.opa
Expand Up @@ -144,7 +144,7 @@ debug(_) = void
ServerI18n = ServerI18n =
{{ {{


default_lang = {en} : I18n.language default_lang = "en" : I18n.language


get_system_lang() = get_system_lang() =
// OS specific // OS specific
Expand Down
12 changes: 6 additions & 6 deletions stdlib/core/i18n/i18n_language.opa

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions stdlib/core/i18n/i18n_region.opa
Expand Up @@ -3,7 +3,8 @@
// DO NOT EDIT // DO NOT EDIT


/* This file contains the utility functions for all subtag described by iana.org language-subtag-registry */ /* 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 / {`AC`} // Ascension
/ {`AD`} // Andorra / {`AD`} // Andorra
/ {`AE`} // United / {`AE`} // United
Expand Down Expand Up @@ -301,17 +302,17 @@ type I18n.region =
/ {`154`} // Northern / {`154`} // Northern
/ {`155`} // Western / {`155`} // Western
/ {`419`} // Latin / {`419`} // Latin

*/
I18n_region = {{ I18n_region = {{


parse(s) : option(I18n.region) = @server parse(s) : option(I18n.region) =
check(s) = match s 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" "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 -> true
_ -> false _ -> false
end 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.