[ 
https://issues.apache.org/jira/browse/ISIS-2987?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andi Huber closed ISIS-2987.
----------------------------

> Although PoReader could translate text without context, can't read it from a 
> file
> ---------------------------------------------------------------------------------
>
>                 Key: ISIS-2987
>                 URL: https://issues.apache.org/jira/browse/ISIS-2987
>             Project: Isis
>          Issue Type: Improvement
>          Components: Isis Core
>    Affects Versions: 2.0.0-M7
>            Reporter: Miklós Győrfi
>            Assignee: Andi Huber
>            Priority: Minor
>             Fix For: 2.0.0-RC1
>
>
> In PoReader  translate(TranslationContext,  String,  ContextAndMsgId.Type) 
> can handle both of contextual and contextless (more generic) translations, 
> which is a good thing. But as 
> org.apache.isis.core.runtimeservices.i18n.po.Block reads the po file, we can 
> not define generic translation, context is a must (contextlist should be 
> non-empty).
> Maybe a new State (GENCONTEXT) is sugested:
> {code:java}
> private enum State {
>     CONTEXT("^#: (?<value>.+)$"),
>     GENCONTEXT("^#:\s*$"),
>     MSGID("^msgid \"(?<value>.+)\"$"),
>     MSGID_PLURAL("^msgid_plural \"(?<value>.+)\"$"),
>     MSGSTR("^msgstr \"(?<value>.+)\"$"),
>     MSGSTR0("^msgstr\\[0\\] \"(?<value>.+)\"$"),
>     MSGSTR1("^msgstr\\[1\\] \"(?<value>.+)\"$"); {code}
> and in parseLine:
>  
> {code:java}
> if (state == State.CONTEXT) {
>     final Matcher contextMatcher = state.pattern.matcher(line);
>     if (contextMatcher.matches()) {
>         final String context = contextMatcher.group("value");
>         contextList.add(context);
>         return this;
>     } else {
>         state = State.GENCONTEXT;
>     }
> }
> if (state == State.GENCONTEXT) {
>     final Matcher contextMatcher = state.pattern.matcher(line);
>     if (contextMatcher.matches()) {
>         contextList.add("");
>         return this;
>     } else {
>         state = State.MSGID;
>         // fallthrough (there may not have been any more context)
>     }
> }
>  {code}
> Maybe contextList is better to be Set, not a List.
>  
> In this case we can use 
> {code:java}
> #: 
> msgid "Anonymous"
> msgstr "Anonim felhasználó"
> {code}
> As generic context.
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to