Repository: WeblateOrg/weblate

Issue:
GWT support
**Is your feature request related to a problem? Please describe.**

Once https://github.com/translate/translate/pull/3885 lands in translate-toolkit, we might add support for that.

**Additional context**

Docs on the format: http://www.gwtproject.org/doc/latest/DevGuideI18nPluralForms.html

<bountysource-plugin>

---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/72008266-gwt-support?utm_campaign=plugin&utm_content=tracker%2F253393&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F253393&utm_medium=issues&utm_source=github).
</bountysource-plugin>


Discussion:

Resolving patch:
diff --git a/weblate/addons/properties.py b/weblate/addons/properties.py
--- a/weblate/addons/properties.py
+++ b/weblate/addons/properties.py
@@ -142,7 +142,7 @@ class PropertiesSortAddon(BaseAddon):
     name = "weblate.properties.sort"
     verbose = _("Formats the Java properties file")
     description = _("This addon sorts the Java properties file.")
-    compat = {"file_format": {"properties-utf8", "properties"}}
+    compat = {"file_format": {"properties-utf8", "properties", "gwt"}}
     icon = "sort-alphabetical.svg"
 
     def pre_commit(self, translation, author):
diff --git a/weblate/formats/models.py b/weblate/formats/models.py
--- a/weblate/formats/models.py
+++ b/weblate/formats/models.py
@@ -69,6 +69,7 @@ class FormatsConf(AppConf):
         "weblate.formats.ttkit.PropertiesUtf16Format",
         "weblate.formats.ttkit.PropertiesFormat",
         "weblate.formats.ttkit.JoomlaFormat",
+        "weblate.formats.ttkit.GWTFormat",
         "weblate.formats.ttkit.PhpFormat",
         "weblate.formats.ttkit.LaravelPhpFormat",
         "weblate.formats.ttkit.RESXFormat",
diff --git a/weblate/formats/ttkit.py b/weblate/formats/ttkit.py
--- a/weblate/formats/ttkit.py
+++ b/weblate/formats/ttkit.py
@@ -206,7 +206,7 @@ def set_target(self, target):
         """Set translation unit target."""
         super().set_target(target)
         # Propagate to value so that is_translated works correctly
-        self.unit.value = self.unit.translation
+        self.unit.value = self.unit.target
 
 
 class TTKitFormat(TranslationFormat):
@@ -1000,6 +1000,13 @@ class JoomlaFormat(PropertiesBaseFormat):
     autoload = ("*.ini",)
 
 
+class GWTFormat(StringsFormat):
+    name = _("GWT Properties")
+    format_id = "gwt"
+    loader = ("properties", "gwtfile")
+    new_translation = "\n"
+
+
 class PhpFormat(TTKitFormat):
     name = _("PHP strings")
     format_id = "php"


Test patch:
diff --git a/weblate/formats/tests/test_formats.py b/weblate/formats/tests/test_formats.py
--- a/weblate/formats/tests/test_formats.py
+++ b/weblate/formats/tests/test_formats.py
@@ -36,6 +36,7 @@
     CSVSimpleFormat,
     DTDFormat,
     FlatXMLFormat,
+    GWTFormat,
     INIFormat,
     InnoSetupINIFormat,
     JoomlaFormat,
@@ -68,6 +69,7 @@
 TEST_JOOMLA = get_test_file("cs.joomla.ini")
 TEST_INI = get_test_file("cs.ini")
 TEST_PROPERTIES = get_test_file("swing.properties")
+TEST_GWT = get_test_file("gwt.properties")
 TEST_ANDROID = get_test_file("strings.xml")
 TEST_XLIFF = get_test_file("cs.xliff")
 TEST_POXLIFF = get_test_file("cs.poxliff")
@@ -165,6 +167,7 @@ class AutoFormatTest(FixtureTestCase, TempDirMixin):
     SUPPORTS_FLAG = True
     EXPECTED_FLAGS = "c-format, max-length:100"
     EDIT_OFFSET = 0
+    EDIT_TARGET = "Nazdar, svete!\n"
 
     def setUp(self):
         super().setUp()
@@ -202,7 +205,7 @@ def test_save(self, edit=False):
 
         if edit:
             units = storage.all_units
-            units[self.EDIT_OFFSET].set_target("Nazdar, svete!\n")
+            units[self.EDIT_OFFSET].set_target(self.EDIT_TARGET)
 
         # Save test file
         storage.save()
@@ -378,6 +381,33 @@ def assert_same(self, newdata, testdata):
         )
 
 
+class GWTFormatTest(AutoFormatTest):
+    FORMAT = GWTFormat
+    FILE = TEST_GWT
+    MIME = "text/plain"
+    COUNT = 1
+    EXT = "properties"
+    MASK = "gwt/gwt_*.properties"
+    EXPECTED_PATH = "gwt/gwt_cs-CZ.properties"
+    FIND = "cartItems"
+    FIND_CONTEXT = "cartItems"
+    FIND_MATCH = "There are {0,number} items in your cart."
+    EDIT_TARGET = [
+        "There are {0,number} goods in your cart.",
+        "There is {0,number} good in your cart.",
+    ]
+    MATCH = "\n"
+    NEW_UNIT_MATCH = b"\nkey=Source string\n"
+    EXPECTED_FLAGS = ""
+    BASE = ""
+
+    def assert_same(self, newdata, testdata):
+        self.assertEqual(
+            force_str(newdata).strip().splitlines(),
+            force_str(testdata).strip().splitlines(),
+        )
+
+
 class JoomlaFormatTest(AutoFormatTest):
     FORMAT = JoomlaFormat
     FILE = TEST_JOOMLA
diff --git a/weblate/trans/tests/data/gwt.properties b/weblate/trans/tests/data/gwt.properties
new file mode 100644
--- /dev/null
+++ b/weblate/trans/tests/data/gwt.properties
@@ -0,0 +1,2 @@
+cartItems=There are {0,number} items in your cart.
+cartItems[one]=There is {0,number} item in your cart.