Miklós Győrfi created ISIS-2987:
-----------------------------------
Summary: 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: Bug
Components: Isis Core
Affects Versions: 2.0.0-M7
Reporter: Miklós Győrfi
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.1#820001)