def calculate_activation(self, ftl_file): translations = self.meao_repo.path.glob(f'*/{ftl_file}') metadata = get_metadata(ftl_file) active_locales = metadata.get('active_locales', []) inactive_locales = metadata.get('inactive_locales', []) percent_required = metadata.get( 'percent_required', settings.FLUENT_DEFAULT_PERCENT_REQUIRED) all_locales = { str(x.relative_to(self.meao_repo.path)).split('/', 1)[0] for x in translations } locales_to_check = all_locales.difference(['en'], active_locales, inactive_locales) new_activations = [] for locale in locales_to_check: l10n = fluent_l10n([locale, 'en'], [ftl_file]) if not l10n.has_required_messages: continue percent_trans = l10n.percent_translated if percent_trans < percent_required: continue new_activations.append(locale) if new_activations: active_locales.extend(new_activations) metadata['active_locales'] = sorted(active_locales) write_metadata(ftl_file, metadata) self.stdout.write( f'Activated {len(new_activations)} new locales for {ftl_file}')
def get_l10n(self, locale): return fluent_l10n([locale, "en"], settings.FLUENT_DEFAULT_FILES)
def get_l10n(locales=None, ftl_files=None): locales = locales or ["de", "en"] ftl_files = ftl_files or ["mozorg/fluent", "brands"] return fluent.fluent_l10n(locales, ftl_files)
def get_l10n(locales=None, ftl_files=None): locales = locales or ['de', 'en'] ftl_files = ftl_files or ['mozorg/fluent', 'brands'] return fluent.fluent_l10n(locales, ftl_files)