Skip to content

Commit

Permalink
guide: Suggest MO compilation addon when MO files are present
Browse files Browse the repository at this point in the history
Fixes #5988
  • Loading branch information
nijel committed May 12, 2021
1 parent e1331d3 commit b965961
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions weblate/trans/guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#

import os

from django.conf import settings
from django.core.cache import cache
from django.template.loader import render_to_string
Expand Down Expand Up @@ -303,3 +305,24 @@ class ConfigureGuideline(AddonGuideline):
@register
class CleanupGuideline(AddonGuideline):
addon = "weblate.cleanup.generic"


@register
class GenerateMoGuideline(AddonGuideline):
addon = "weblate.gettext.mo"

def is_relevant(self):
if not super().is_relevant():
return False
component = self.component
translations = component.translation_set.exclude(
pk=component.source_translation.id
)
try:
translation = translations[0]
except IndexError:
return False
if not translation.filename.endswith(".po"):
return False
mofilename = translation.get_filename()[:-3] + ".mo"
return os.path.exists(mofilename)

0 comments on commit b965961

Please sign in to comment.