Commit c1533a82 authored by Weblate's avatar Weblate

Merge remote-tracking branch 'origin/master'

parents f10fcacb 6ce90f1f
...@@ -9,6 +9,21 @@ tested formats. ...@@ -9,6 +9,21 @@ tested formats.
.. seealso:: `Supported formats in translate-toolkit`_ .. seealso:: `Supported formats in translate-toolkit`_
Weblate does support both monolingual and bilingual formats. Bilingual formats
store two languages in single file - source and translation (typical examples
is :ref:`gettext`, :ref:`xliff` or :ref:`apple`). On the other side,
monolingual formats identify the string by ID and each language file contains
only mapping of those to given language (typically :ref:`aresource`). Some file
formats are used in both variants, see detailed description below.
For correct use of monolingual files, Weblate requires access to file
containing complete list of strings to translate with their source - this file
is called :guilabel:`template` within Weblate, though the naming might vary in
your application.
.. _gettext:
GNU Gettext GNU Gettext
----------- -----------
...@@ -28,12 +43,16 @@ in their source code and the string needs to be translated to all languages, ...@@ -28,12 +43,16 @@ in their source code and the string needs to be translated to all languages,
including English. Weblate does support this, though you have to choose explicitely including English. Weblate does support this, though you have to choose explicitely
this file format when importing resources into Weblate. this file format when importing resources into Weblate.
.. _xliff:
XLIFF XLIFF
----- -----
XML based format created to standardize translation files, but in the end it XML based format created to standardize translation files, but in the end it
is one of many standards in this area. is one of many standards in this area.
XLIFF is usually used as bilingual.
.. seealso:: https://en.wikipedia.org/wiki/XLIFF .. seealso:: https://en.wikipedia.org/wiki/XLIFF
Java properties Java properties
...@@ -41,6 +60,8 @@ Java properties ...@@ -41,6 +60,8 @@ Java properties
Native Java format for translations. Native Java format for translations.
Java properties are usually used as bilingual.
.. seealso:: https://en.wikipedia.org/wiki/.properties .. seealso:: https://en.wikipedia.org/wiki/.properties
Qt Linguist .ts Qt Linguist .ts
...@@ -48,13 +69,20 @@ Qt Linguist .ts ...@@ -48,13 +69,20 @@ Qt Linguist .ts
Translation format used in Qt based applications. Translation format used in Qt based applications.
Qt Linguist files are used as both bilingual and monolingual.
.. seealso:: http://qt-project.org/doc/qt-4.8/linguist-manual.html .. seealso:: http://qt-project.org/doc/qt-4.8/linguist-manual.html
.. _aresource:
Android string resources Android string resources
------------------------ ------------------------
Android specific file format for translating applications. Android specific file format for translating applications.
Android string resources are monolingual, the :guilabel:`template` file being
stored in different location than others :file:`res/values/strings.xml`.
.. seealso:: https://developer.android.com/guide/topics/resources/string-resource.html .. seealso:: https://developer.android.com/guide/topics/resources/string-resource.html
.. note:: .. note::
...@@ -62,12 +90,16 @@ Android specific file format for translating applications. ...@@ -62,12 +90,16 @@ Android specific file format for translating applications.
This format is not yet supported by Translate-toolkit (merge request is This format is not yet supported by Translate-toolkit (merge request is
pending), but Weblate includes own support for it. pending), but Weblate includes own support for it.
.. _apple:
Apple OS X strings Apple OS X strings
------------------ ------------------
Apple specific file format for translating applications, used for both OS X Apple specific file format for translating applications, used for both OS X
and iPhone/iPad application translations. and iPhone/iPad application translations.
Apple OS X strings are usually used as bilingual.
.. seealso:: https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPInternational/Articles/StringsFiles.html .. seealso:: https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPInternational/Articles/StringsFiles.html
.. note:: .. note::
......
...@@ -832,6 +832,10 @@ class SubProject(models.Model, PercentMixin, URLMixin): ...@@ -832,6 +832,10 @@ class SubProject(models.Model, PercentMixin, URLMixin):
# Validate template # Validate template
if self.has_template(): if self.has_template():
self.clean_template() self.clean_template()
elif self.file_format_cls.monolingual:
raise ValidationError(
_('You can not use monolingual translation without template!')
)
def get_template_filename(self): def get_template_filename(self):
''' '''
......
...@@ -76,7 +76,7 @@ class Suggestion(models.Model, RelatedUnitMixin): ...@@ -76,7 +76,7 @@ class Suggestion(models.Model, RelatedUnitMixin):
def delete(self, *args, **kwargs): def delete(self, *args, **kwargs):
super(Suggestion, self).delete(*args, **kwargs) super(Suggestion, self).delete(*args, **kwargs)
# Update unit flags # Update unit flags
for unit in suggestion.get_related_units(): for unit in self.get_related_units():
unit.update_has_suggestion() unit.update_has_suggestion()
def get_matching_unit(self): def get_matching_unit(self):
...@@ -120,7 +120,7 @@ class Comment(models.Model, RelatedUnitMixin): ...@@ -120,7 +120,7 @@ class Comment(models.Model, RelatedUnitMixin):
def delete(self, *args, **kwargs): def delete(self, *args, **kwargs):
super(Suggestion, self).delete(*args, **kwargs) super(Suggestion, self).delete(*args, **kwargs)
# Update unit flags # Update unit flags
for unit in suggestion.get_related_units(): for unit in self.get_related_units():
unit.update_has_comment() unit.update_has_comment()
CHECK_CHOICES = [(x, CHECKS[x].name) for x in CHECKS] CHECK_CHOICES = [(x, CHECKS[x].name) for x in CHECKS]
......
...@@ -358,6 +358,7 @@ class EditTest(ViewTestCase): ...@@ -358,6 +358,7 @@ class EditTest(ViewTestCase):
self.assertEqual(unit.target, 'Nazdar svete!') self.assertEqual(unit.target, 'Nazdar svete!')
self.assertTrue(unit.has_failing_check) self.assertTrue(unit.has_failing_check)
self.assertEqual(len(unit.checks()), 2) self.assertEqual(len(unit.checks()), 2)
self.assertEqual(len(unit.active_checks()), 2)
# Ignore one of checks # Ignore one of checks
check_id = unit.checks()[0].id check_id = unit.checks()[0].id
...@@ -368,7 +369,8 @@ class EditTest(ViewTestCase): ...@@ -368,7 +369,8 @@ class EditTest(ViewTestCase):
# Should have one less check # Should have one less check
unit = self.translation.unit_set.get(source='Hello, world!\n') unit = self.translation.unit_set.get(source='Hello, world!\n')
self.assertTrue(unit.has_failing_check) self.assertTrue(unit.has_failing_check)
self.assertEqual(len(unit.checks()), 1) self.assertEqual(len(unit.checks()), 2)
self.assertEqual(len(unit.active_checks()), 1)
# Save with no failing checks # Save with no failing checks
response = self.edit_unit( response = self.edit_unit(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment