Repository: WeblateOrg/weblate

Issue:
Allow GenerateMoAddon to export fuzzy strings
### Describe the problem

We use the 'fuzzy' marking to mark texts that need to be reviewed by our translators. However, we would like to use those texts in our application as soon as possible.

Right now, the addon `GenerateMoAddon` is programmed such that only units with a state greater than or equal to `STATE_TRANSLATED` are exported. 

### Describe the solution you'd like

It would be great for us if a configuration item could be added that allows us to export units with state `STATE_FUZZY` or greater.

### Describe alternatives you've considered

I could investigate using the review workflow, but this is a project-wide settings and I would like to use this on a component level.

### Screenshots

_No response_

### Additional context

_No response_


Discussion:
This issue seems to be a good fit for newbie contributors. You are welcome to contribute to Weblate! Don't hesitate to ask any questions you would have while implementing this.

You can learn about how to get started in our [contributors documentation](https://docs.weblate.org/en/latest/contributing/index.html).
It should be easy to add this as an option, it used to include all strings due to a bug until 899a7421b2ad388a24b9b328eba5d7230722ba22.
Hello @nijel and @jorrit, I am working on this issue. By the time can you give me a brief idea about the solution you would like to implement? 
Also, how do i replicate this issue? I have weblate setup onto my local machine.
I'd think it would just be a checkbox 'Add fuzzy strings' that changes `STATE_TRANSLATED` to `STATE_FUZZY` in the implementation.
I have come up with a solution. Just wanted to check wether its working. Are there any sample repositories or translation files so that I could test the solution? I was unable to find any that has fuzzy strings.
You can just check the 'Needs editing' checkbox for an existing translation. That will make the translation fuzzy.

![image](https://github.com/WeblateOrg/weblate/assets/521449/ec9fb784-60ae-485d-9240-8e390cad104e)


Resolving patch:
diff --git a/weblate/addons/forms.py b/weblate/addons/forms.py
--- a/weblate/addons/forms.py
+++ b/weblate/addons/forms.py
@@ -46,6 +46,13 @@ class GenerateMoForm(BaseAddonForm):
             "If not specified, the location of the PO file will be used."
         ),
     )
+    fuzzy = forms.BooleanField(
+        label=gettext_lazy("Include strings needing editing"),
+        required=False,
+        help_text=gettext_lazy(
+            "Strings needing editing (fuzzy) are typically not ready for use as translations."
+        ),
+    )
 
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
diff --git a/weblate/addons/gettext.py b/weblate/addons/gettext.py
--- a/weblate/addons/gettext.py
+++ b/weblate/addons/gettext.py
@@ -13,7 +13,7 @@
 from weblate.addons.forms import GenerateMoForm, GettextCustomizeForm, MsgmergeForm
 from weblate.formats.base import UpdateError
 from weblate.formats.exporters import MoExporter
-from weblate.utils.state import STATE_TRANSLATED
+from weblate.utils.state import STATE_FUZZY, STATE_TRANSLATED
 
 
 class GettextBaseAddon(BaseAddon):
@@ -31,9 +31,14 @@ class GenerateMoAddon(GettextBaseAddon):
 
     def pre_commit(self, translation, author):
         exporter = MoExporter(translation=translation)
-        exporter.add_units(
-            translation.unit_set.filter(state__gte=STATE_TRANSLATED).prefetch_full()
-        )
+
+        if self.instance.configuration.get("fuzzy"):
+            state = STATE_FUZZY
+        else:
+            state = STATE_TRANSLATED
+        units = translation.unit_set.filter(state__gte=state)
+
+        exporter.add_units(units.prefetch_full())
 
         template = self.instance.configuration.get("path")
         if not template:


Test patch: