Uploaded image for project: 'Apache Freemarker'
  1. Apache Freemarker
  2. FREEMARKER-208

Allow to provide a specific locale for lower_case / upper_case

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Implemented
    • None
    • 2.3.32
    • None
    • None

    Description

      lower_case and upper_case filters rely on toLowerCase / toUpperCase methods. They use the current environment locale as first and only parameter for these methods.

      https://github.com/apache/freemarker/blob/201533eb7c15e3cfc55b38da37f730a3492bec0f/src/main/java/freemarker/core/BuiltInsForStringsBasic.java#L433

      In rare cases, we might want to provide a specific/fixed locale, to avoid some weird problems, such as the Turkish/Azeri dotless i problem :

      // lowercasing an uppercase i, using turkish locale
      System.out.println("I".toLowerCase(new Locale("tr", "TR")));

      ...will output "ı" (which is a dotless "i").

      We faced this problem in OFBiz (https://issues.apache.org/jira/browse/OFBIZ-12660), and although we can fix this for our specific use case, it may be a good idea to be able to pass a locale (which sould defaults to the environment locale if not provided) as parameter for lower_case and upper_case :

      myVar?lower_case("en", "EN") 

      Attachments

        Activity

          People

            ddekany Dániel Dékány
            FloMo Florian Motteau
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: