Repository: WeblateOrg/weblate

Issue:
Add support for ResourceDictionary
### Describe the problem

ResourceDictionary format is not supported.

### Describe the solution you'd like

https://github.com/translate/translate/issues/4589 will implement support in translate-toolkit

### Describe alternatives you've considered

_No response_

### Screenshots

_No response_

### Additional context

_No response_


Discussion:
The issue you've reported needs to be addressed in the [translate-toolkit](https://github.com/translate/translate/). Please file the issue there, and include links to any relevant specifications about the formats (if applicable).
From https://github.com/translate/translate/issues/4589#issuecomment-1092927891:

Because the base language is C# the placeholders seems to be the same as[ commonly in C#](https://docs.microsoft.com/en-us/dotnet/standard/base-types/composite-formatting) ({0} or {1:tt}).

Resolving patch:
diff --git a/weblate/formats/models.py b/weblate/formats/models.py
--- a/weblate/formats/models.py
+++ b/weblate/formats/models.py
@@ -132,6 +132,7 @@ class FormatsConf(AppConf):
         "weblate.formats.ttkit.SubStationAlphaFormat",
         "weblate.formats.ttkit.DTDFormat",
         "weblate.formats.ttkit.FlatXMLFormat",
+        "weblate.formats.ttkit.ResourceDictionaryFormat",
         "weblate.formats.ttkit.INIFormat",
         "weblate.formats.ttkit.InnoSetupINIFormat",
         "weblate.formats.ttkit.PropertiesMi18nFormat",
diff --git a/weblate/formats/ttkit.py b/weblate/formats/ttkit.py
--- a/weblate/formats/ttkit.py
+++ b/weblate/formats/ttkit.py
@@ -1641,6 +1641,19 @@ class FlatXMLFormat(TTKitFormat):
     new_translation = '<?xml version="1.0" encoding="utf-8"?>\n<root></root>'
 
 
+class ResourceDictionaryFormat(FlatXMLFormat):
+    name = _("ResourceDictionary file")
+    format_id = "resourcedictionary"
+    loader = ("resourcedictionary", "ResourceDictionaryFile")
+    check_flags = ("c-sharp-format",)
+    language_format = "java"
+    new_translation = """<ResourceDictionary
+  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+  xmlns:system="clr-namespace:System;assembly=mscorlib">
+</ResourceDictionary>"""
+
+
 class INIFormat(TTKitFormat):
     name = _("INI file")
     format_id = "ini"


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
@@ -47,6 +47,7 @@
     PoFormat,
     PoXliffFormat,
     PropertiesFormat,
+    ResourceDictionaryFormat,
     RESXFormat,
     RubyYAMLFormat,
     StringsdictFormat,
@@ -69,6 +70,7 @@
 TEST_CSV = get_test_file("cs-mono.csv")
 TEST_CSV_NOHEAD = get_test_file("cs.csv")
 TEST_FLATXML = get_test_file("cs-flat.xml")
+TEST_RESOURCEDICTIONARY = get_test_file("cs.xaml")
 TEST_JSON = get_test_file("cs.json")
 TEST_NESTED_JSON = get_test_file("cs-nested.json")
 TEST_WEBEXT_JSON = get_test_file("cs-webext.json")
@@ -867,6 +869,24 @@ class FlatXMLFormatTest(AutoFormatTest):
     MONOLINGUAL = True
 
 
+class ResourceDictionaryFormatTest(AutoFormatTest):
+    FORMAT = ResourceDictionaryFormat
+    FILE = TEST_RESOURCEDICTIONARY
+    MIME = "application/xaml+xml"
+    COUNT = 2
+    EXT = "xaml"
+    MASK = "Languages/*.xaml"
+    BASE = TEST_RESOURCEDICTIONARY
+    EXPECTED_PATH = "Languages/cs-CZ.xaml"
+    MATCH = "hello"
+    FIND = "Hello World!"
+    FIND_CONTEXT = "hello_world"
+    FIND_MATCH = "Hello World!"
+    NEW_UNIT_MATCH = b'<system:String x:Key="key">Source string</system:String>\n'
+    EXPECTED_FLAGS = ""
+    MONOLINGUAL = True
+
+
 class INIFormatTest(AutoFormatTest):
     FORMAT = INIFormat
     FILE = TEST_INI
diff --git a/weblate/trans/tests/data/cs.xaml b/weblate/trans/tests/data/cs.xaml
new file mode 100644
--- /dev/null
+++ b/weblate/trans/tests/data/cs.xaml
@@ -0,0 +1,4 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
+    <system:String x:Key="hello_world">Hello World!</system:String>
+    <system:String x:Key="resource_key">Translated value.</system:String>
+</ResourceDictionary>