Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-6826

i18n: Supported nested keys in JSON i18n files

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • i18n 2.5.8
    • None
    • i18n
    • None

    Description

      i18n supports resource files stored as JSON binary files in the repository:
      https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html#json-file-based

      currently nested key structures are not really supported - from the docs page:

      The parser will take any "key":"value" pair in the JSON file, including those in nested objects or arrays. Normally, a dictionary will be just a single json object = hash map though.

      that means that these two JSON example will produc the same result:
      A)

      {
        "key1": "value1",
        "key2": "value2",
        "key3": "value3"
      }
      

      B)

      {
        "level1": {
          "key1": "value1",
          "level2: {
            "key2": "value2",
            "level3": {
              "key3": "value3"
            }
          }
        }
      }
      

      in both cases the keys are just

      key1
      key2
      key3
      

      the goal of this ticket is to interpret the nested JSON object structure as parts of the i18n keys, so that example B would produce these keys:

      level1.key1
      level1.level2.key2
      level1.level2.level3.key3
      

      as statet in the documentation in most cases people will only use the JSON as key/value map file with no hierarchies at all. in this case the result is the same. but if someone used hierarchies this ticket will create a backward compatibility issue. i will start a discussion on the sling-dev list about this.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              sseifert Stefan Seifert
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: