Question about internationalization

99 views
Skip to first unread message

green

unread,
Aug 6, 2010, 10:58:14 PM8/6/10
to play-fr...@googlegroups.com
Hi Play,

I am preparing message files for both Simplified and Transitional Chinese. I named my 2 messages files as 
1. messages.zh-cn (for Simplified Chinese)
2. messages.zh-tw (for Transitional Chinese)

However, I found none of them are working. I tried to check Play.i18n.Lang, and found these code in resolvefrom method:

67     for (String a: request.acceptLanguage()) {
            if (a.indexOf("-") > 0) {
                a = a.substring(0, a.indexOf("-"));
            }
            for (String locale: Play.langs) {
                if (locale.equals(a)) {
                    set(locale);
                    return;
                }
            }
 77   }

Obviously, zh-cn and zh-tw won't work as only string before '-' will be used to set the locale. Then I copy messages.zh-ch to messages.zh, changed the application.langs setting in application.conf file accordingly, and it works. However, this won't suit my case as I need both zh-cn and zh-tw. Can you help out?

BTW, I am using Play v1.0.3

Thx,
Green

Minghui Zheng

unread,
Aug 7, 2010, 5:21:45 AM8/7/10
to play-fr...@googlegroups.com
It seems like play! only supports ISO639.

> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.
>

Guillaume Bort

unread,
Aug 7, 2010, 6:49:11 AM8/7/10
to play-fr...@googlegroups.com
Well, a simple solution is to create fake locale codes, like cn & tw,
instead of zh-cn and zh-tw.

--
Guillaume Bort, http://guillaume.bort.fr

For anything work-related, use g...@zenexity.fr; for everything else,
write guillau...@gmail.com

green

unread,
Aug 7, 2010, 11:51:15 PM8/7/10
to play-fr...@googlegroups.com
I am afraid this solution won't work if you relies on "accept-language" to determine which locale to use. I don't think we can force user agent to use those faked locale codes.

Guillaume Bort

unread,
Aug 8, 2010, 8:20:34 AM8/8/10
to play-fr...@googlegroups.com
No but you can manage it yourself. Just use a before filter to read and parse the accept-language yourself. 

GrailsDeveloper

unread,
Aug 8, 2010, 9:40:12 AM8/8/10
to play-framework
In this case I think a module with a plugin (see the module docviewer)
is the better choice because this must be done for every request.
But I think this case has to aspects:
1. green needs a quick fix and I think the hint of Guillaume is a good
idea.

2. Should the framework extended support for internationalization? I
think this is still useful, so I would think a wish in the ticket-
datebase could be useful.

Just my thoughts
Niels

On 8 Aug., 14:20, Guillaume Bort <guillaume.b...@gmail.com> wrote:
> No but you can manage it yourself. Just use a before filter to read  
> and parse the accept-language yourself.
>
> Le 8 août 2010 à 05:51, green <greenlaw...@gmail.com> a écrit :
>
> > I am afraid this solution won't work if you relies on "accept-
> > language" to determine which locale to use. I don't think we can  
> > force user agent to use those faked locale codes.
>
> > On Sat, Aug 7, 2010 at 8:49 PM, Guillaume Bort <guillaume.b...@gmail.com
> > > wrote:
> > Well, a simple solution is to create fake locale codes, like cn & tw,
> > instead of zh-cn and zh-tw.
>
> > On Sat, Aug 7, 2010 at 11:21 AM, Minghui Zheng <lanc...@gmail.com>  
> > wrote:
> > > It seems like play! only supports ISO639.
>
> > > On Sat, Aug 7, 2010 at 10:58 AM, green <greenlaw...@gmail.com>  
> > fram...@googlegroups.com.
> > > To unsubscribe from this group, send email to play-framewor...@googlegroups.com
> > .
> > > For more options, visit this group athttp://groups.google.com/group/play-framework?hl=en
> > .
>
> > --
> > Guillaume Bort,http://guillaume.bort.fr
>
> > For anything work-related, use g...@zenexity.fr; for everything else,
> > write guillaume.b...@gmail.com
Reply all
Reply to author
Forward
0 new messages