Initialize translations for a language code.
432054
def init(lang, domain):
    
    translations_dir = _get_translations_dir()
    domain = _get_translations_domain(domain)
    pot = os.path.join(translations_dir, f'{domain}.pot')
    return _run(f'init -i {pot} -d {translations_dir} -l {lang} --domain={domain}')
219537
def code(self, text, lang=None):
        """"""
        # WARNING: lang is discarded currently.
        with self.paragraph(stylename='code'):
            lines = text.splitlines()
            for line in lines[:-1]:
                self._code_line(line)
                self.linebreak()
            self._code_line(lines[-1])
468899
public static function registerTranslations()
    {
        if (!isset(Yii::$app->i18n->translations[static::getThemePath() . '/*']) && !isset(Yii::$app->i18n->translations[static::getThemePath()])) {
            Yii::$app->i18n->translations[static::getThemePath() . '/*'] = [
                'class' => 'yii\i18n\PhpMessageSource',
                'sourceLanguage' => 'en-US',
                'basePath' => static::getThemePath() . '/messages',
                'fileMap' => [
                    static::getThemePath() . '/message' => 'message.php',
                ],
            ];
        }
    }
189687
private void initLocales() {

        if (!m_localeCache.isEmpty()) {
            return;
        }
        readLocale(m_primaryResource);
        for (CmsResource resource : m_secondaryResources) {
            readLocale(resource);
        }
        for (Map.Entry<CmsResource, Locale> entry : m_localeCache.entrySet()) {
            CmsResource key = entry.getKey();
            Locale value = entry.getValue();
            m_resourcesByLocale.put(value, key);
        }
        try {
            CmsProperty noTranslationProp = m_cms.readPropertyObject(
                m_primaryResource,
                CmsPropertyDefinition.PROPERTY_LOCALE_NOTRANSLATION,
                false);
            m_noTranslation = noTranslationProp.getValue();
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);

        }
    }
507083
def _init_loaders(self) -> None:
        

        for loader in settings.I18N_TRANSLATION_LOADERS:
            loader_class = import_class(loader['loader'])
            instance = loader_class()
            instance.on_update(self.update)
            run(instance.load(**loader['params']))
166479
def translate(self):
        """"""
        visitor = CheckTranslator(self.document,
                                  contents=self.contents,
                                  filename=self.filename,
                                  ignore=self.ignore)
        self.document.walkabout(visitor)
        self.checkers += visitor.checkers
238417
def process_LANGUAGE_CODE(self, language_code, data):
        '''
        
        '''
        # Dirty hack to fix non included default
        language_code = 'en-us' if language_code == 'en' else language_code
        language = translation.get_language_info('en' if language_code == 'en-us' else language_code)
        if not settings.JS_CONTEXT or 'LANGUAGE_NAME' in settings.JS_CONTEXT \
            or (settings.JS_CONTEXT_EXCLUDE and 'LANGUAGE_NAME' in settings.JS_CONTEXT_EXCLUDE):
            data['LANGUAGE_NAME'] = language['name']
        if not settings.JS_CONTEXT or 'LANGUAGE_NAME_LOCAL' in settings.JS_CONTEXT \
            or (settings.JS_CONTEXT_EXCLUDE and 'LANGUAGE_NAME_LOCAL' in settings.JS_CONTEXT_EXCLUDE):
            data['LANGUAGE_NAME_LOCAL'] = language['name_local']
        return language_code
551271
protected function _initTranslate()
    {
        $this->bootstrap('locale');

        $language = $this->locale->getLanguage();

        /*
         * Scan for files with -<languagecode> and disable notices when the requested
         * language is not found
         */
        $options = array( 'adapter'         => 'gettext',
                          'content'         => GEMS_LIBRARY_DIR . '/languages/',
                          'disableNotices'  => true,
                          'scan'            => \Zend_Translate::LOCALE_FILENAME);

        $translate = new \Zend_Translate($options);

        // If we don't find the needed language, use a fake translator to disable notices
        if (! $translate->isAvailable($language)) {
            $translate = \MUtil_Translate_Adapter_Potemkin::create();
        }

        //Now if we have a project specific language file, add it
        $projectLanguageDir = APPLICATION_PATH . '/languages/';
        if (file_exists($projectLanguageDir)) {
            $options['content']        = $projectLanguageDir;
            $options['disableNotices'] = true;
            $projectTranslations       = new \Zend_Translate($options);
            //But only when it has the requested language
            if ($projectTranslations->isAvailable($language)) {
                $translate->addTranslation(array('content' => $projectTranslations));
            }
            unset($projectTranslations);  //Save some memory
        }

        $translate->setLocale($language);
        \Zend_Registry::set('Zend_Translate', $translate);

        // Fix for _init resource being case insensitive
        $container = $this->getContainer();
        $adapter   = $translate->getAdapter();
        $container->translateAdapter = $adapter;
        $this->translateAdapter      = $adapter;

        return $translate;
    }
338147
private void iniLanguage(CmsUserSettings settings) {

        m_language.setContainerDataSource(CmsVaadinUtils.getLanguageContainer("caption"));
        m_language.setItemCaptionPropertyId("caption");
        m_language.setNewItemsAllowed(false);
        m_language.setNullSelectionAllowed(false);
        if (settings != null) {
            m_language.select(settings.getLocale());
        } else {
            m_language.select(m_language.getItemIds().iterator().next());
        }
    }
1083405
def set_current_language(self, language_code, initialize=False):
        
        self._current_language = normalize_language_code(language_code or get_language())

        # Ensure the translation is present for __get__ queries.
        if initialize:
            self._get_translated_model(use_fallback=False, auto_create=True)
314797
private void initializeLocale() {
        final String locale = getProperty(LOCALE, applicationProperties);
        if (locale != null && !"".equals(locale)) {
            final String[] localeParts = locale.split("_");
            if (localeParts.length == 2) {
                currentLocale = new Locale(localeParts[0], localeParts[1]);
            } else {
                currentLocale = new Locale(localeParts[0]);
            }
        } else {
            currentLocale = Locale.getDefault();
        }
        logger.info(Messages.getMessage(CONTEXT_LOCALE_USED), currentLocale);
    }
905848
protected function wizardAddLanguage()
    {
        $this->validatePrompt('code', $this->text('Code'), 'language');
        $this->validatePrompt('name', $this->text('Name'), 'language', '');
        $this->validatePrompt('native_name', $this->text('Native name'), 'language', '');
        $this->validatePrompt('status', $this->text('Status'), 'language', 0);
        $this->validatePrompt('default', $this->text('Default') . '?', 'language', 0);
        $this->validatePrompt('weight', $this->text('Weight'), 'language', 0);
        $this->validatePrompt('rtl', $this->text('Right-to-left') . '?', 'language', 0);

        $this->validateComponent('language');
        $this->addLanguage();
    }
764447
def _construct_form(self, i, **kwargs):
        
        if not settings.HIDE_LANGUAGE:
            self._construct_available_languages()

        form = super(TranslationFormSet, self)._construct_form(i, **kwargs)

        if settings.HIDE_LANGUAGE:
            form.instance.language_code = settings.DEFAULT_LANGUAGE
        else:
            language_code = form.instance.language_code

            if language_code:
                logger.debug(
                    u'Removing translation choice %s for instance %s'
                    u' in form %d', language_code, form.instance, i
                )

                self.available_languages.remove(language_code)

            else:
                initial_language_code = self._get_default_language()

                logger.debug(
                    u'Preselecting language code %s for form %d',
                    initial_language_code, i
                )

                form.initial['language_code'] = initial_language_code

        return form
616361
protected void init(int code, String phrase, boolean isError) {
        this.myPhrase = phrase;
        this.myPhraseBytes = HttpChannelUtils.getEnglishBytes(phrase);
        this.myIntCode = code;
        if (isError) {
            this.myError = new HttpError(code, this.myPhrase);
        }
        initSpecialArrays();
        checkForAllowedBody();
    }
1097832
protected function initTranslations()
    {
        /** @var \yii\i18n\I18N $i18n */
        $i18n = Instance::ensure($this->i18n, \yii\i18n\I18N::class);
        $i18n->translations['recaptcha*'] = [
            'class' => PhpMessageSource::class,
            'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'messages',
            'sourceLanguage' => 'en',
            'fileMap' => [
                'recaptcha' => 'recaptcha.php',
            ],
        ];
    }
273372
def add_localedir_translations(self, localedir):
        """"""
        global _localedirs
        if localedir in self.localedirs:
            return
        self.localedirs.append(localedir)
        full_localedir = os.path.join(localedir, 'locale')
        if os.path.exists(full_localedir):
            translation = self._new_gnu_trans(full_localedir)
            self.merge(translation)
552023
def input(self, _in, out, **kwargs):
        """"""
        language_code = _re_language_code.search(_in.read()).group(
            'language_code'
        )
        _in.seek(0)  # move at the begining after matching the language
        catalog = read_po(_in)
        out.write('gettextCatalog.setStrings("{0}", '.format(language_code))
        out.write(json.dumps({
            key: value.string for key, value in catalog._messages.items()
            if key and value.string
        }))
        out.write(');')