Uploaded image for project: 'Causeway'
  1. Causeway
  2. CAUSEWAY-2987

Although PoReader could translate text without context, can't read it from a file

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.0-M7
    • 2.0.0-M8
    • Core
    • None

    Description

      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:

      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>.+)\"$"); 

      and in parseLine:

       

      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)
          }
      }
       

      Maybe contextList is better to be Set, not a List.

       

      In this case we can use 

      #: 
      msgid "Anonymous"
      msgstr "Anonim felhasználó"
      

      As generic context.

       

       

       

      Attachments

        Activity

          People

            hobrom Andi Huber
            gyorfimi Miklós Győrfi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: