Adds data for the given language.

@param \Aimeos\MW\Container\Content\Iface $contentItem Content item
@param string $langid Language ID to add the texts for
@param array $ids List of of item ids whose texts should be added
979453
protected function addLanguage( \Aimeos\MW\Container\Content\Iface $contentItem, $langid, array $ids )
	{
		$manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->getContext() );

		foreach( $ids as $id )
		{
			foreach( $this->getNodeList( $manager->getTree( $id, array( 'text' ) ) ) as $item ) {
				$this->addItem( $contentItem, $item, $langid );
			}
		}
	}
1294047
protected function addTranslate( \Aimeos\MW\View\Iface $view, $locale )
	{
		if( $locale !== null )
		{
			$i18n = $this->container->get( 'aimeos.i18n' )->get( array( $locale ) );
			$translation = $i18n[$locale];
		}
		else
		{
			$translation = new \Aimeos\MW\Translation\None( 'en' );
		}

		$helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $translation );
		$view->addHelper( 'translate', $helper );

		return $view;
	}
115541
public function addText($locale, $text, $id = null)
    {
        $textWithLocale = new TextWithLocale();
        $textWithLocale
            ->setLocale($locale)
            ->setText($text);
        if (!is_null($id)) {
            $textWithLocale->setId($id);
        }
        $this->texts->add($textWithLocale);

        return $this;
    }
348459
public function translateItem($id, $lang)
	{
		$model = $this->crud['model'];
		$this->data['entry'] = $model::find($id);
		// check if there isn't a translation already
		$existing_translation = $this->data['entry']->translation($lang);

		if ($existing_translation)
		{
			$new_entry = $existing_translation;
		}
		else
		{
			// get the info for that entry
			$new_entry_attributes = $this->data['entry']->getAttributes();
			$new_entry_attributes['translation_lang'] = $lang;
			$new_entry_attributes['translation_of'] = $id;
			$new_entry_attributes = array_except($new_entry_attributes, 'id');

			$new_entry = $model::create($new_entry_attributes);
		}

		// redirect to the edit form for that translation
		return redirect(str_replace($id, $new_entry->id, str_replace('translate/'.$lang, 'edit', \Request::url())));
	}
955644
protected function getNotificationContentData($fluent, $langId, $key = 'title')
    {
        foreach ($fluent->contents as $content) {
            if ($langId !== $content['lang_id']) {
                continue;
            }
            return array_get($content, $key);
        }
        return '';
    }
54461
public static function loadLanguages($langId = null, $backend = false)
    {
        // Configure all available frontend and backend languages.
        $languages = Cache::remember('languages', function () {
            /** @var LanguagesTable $Languages */
            $Languages = TableRegistry::get('Wasabi/Core.Languages');
            $langs = $Languages->find('allFrontendBackend')->all();

            return [
                'frontend' => array_values($Languages->filterFrontend($langs)->toArray()),
                'backend' => array_values($Languages->filterBackend($langs)->toArray())
            ];
        }, 'wasabi/core/longterm');
        Configure::write('languages', $languages);

        if ($backend === true) {
            // Backend
            $request = Router::getRequest();

            // Setup the users backend language.
            $backendLanguage = $languages['backend'][0];
            if ($request->session()->check('Auth.User.language_id')) {
                $backendLanguageId = $request->session()->read('Auth.User.language_id');

                if ($backendLanguageId !== null) {
                    foreach ($languages['backend'] as $lang) {
                        if ($lang->id === $backendLanguageId) {
                            $backendLanguage = $lang;
                            break;
                        }
                    }
                }
            }

            // Setup the users content language.
            $contentLanguage = $languages['frontend'][0];
            if ($request->session()->check('contentLanguageId')) {
                $contentLanguageId = $request->session()->read('contentLanguageId');
                foreach ($languages['frontend'] as $lang) {
                    if ($lang->id === $contentLanguageId) {
                        $contentLanguage = $lang;
                        break;
                    }
                }
            }
            Configure::write('contentLanguage', $contentLanguage);
            Configure::write('backendLanguage', $backendLanguage);
            I18n::locale($backendLanguage->iso2);
        } else {
            // Frontend
            if ($langId !== null) {
                foreach ($languages['frontend'] as $frontendLanguage) {
                    if ($frontendLanguage->id === $langId) {
                        Configure::write('contentLanguage', $frontendLanguage);
                        I18n::locale($frontendLanguage->iso2);
                        break;
                    }
                }
            } else {
                Configure::write('contentLanguage', $languages['frontend'][0]);
                I18n::locale($languages['frontend'][0]->iso2);
            }
        }
    }
879473
protected function getFieldIds($contentId, array $fieldIdentifiers)
    {
        $ids = [];
        foreach ($fieldIdentifiers as $identifier) {
            try {
                $ids[] = $this->contentTypeUtils->getFieldId($contentId, $identifier);
            } catch (OutOfBoundsException $e) {
                continue;
            }
        }

        return $ids;
    }
803950
protected function updateLineItems(int $iInvoiceId, array $aItems): void
    {
        $oItemModel  = Factory::model('InvoiceItem', 'nails/module-invoice');
        $aTouchedIds = [];

        //  Update/insert all known items
        foreach ($aItems as $aItem) {

            $aData = [
                'label'         => getFromArray('label', $aItem, null),
                'body'          => getFromArray('body', $aItem, null),
                'order'         => getFromArray('order', $aItem, 0),
                'currency'      => getFromArray('currency', $aItem, null),
                'unit'          => getFromArray('unit', $aItem, null),
                'tax_id'        => getFromArray('tax_id', $aItem, null),
                'quantity'      => getFromArray('quantity', $aItem, 1),
                'unit_cost'     => getFromArray('unit_cost', $aItem, 0),
                'sub_total'     => getFromArray('sub_total', $aItem, 0),
                'tax_total'     => getFromArray('tax_total', $aItem, 0),
                'grand_total'   => getFromArray('grand_total', $aItem, 0),
                'callback_data' => getFromArray('callback_data', $aItem, null),
            ];

            //  Ensure callback data is encoded as JSON
            if (array_key_exists('callback_data', $aData)) {
                $aData['callback_data'] = json_encode($aData['callback_data']);
            }

            if (!empty($aItem['id'])) {

                //  Update
                if (!$oItemModel->update($aItem['id'], $aData)) {
                    throw new InvoiceException('Failed to update invoice item.', 1);
                } else {
                    $aTouchedIds[] = $aItem['id'];
                }

            } else {

                //  Insert
                $aData['invoice_id'] = $iInvoiceId;
                $iItemId             = $oItemModel->create($aData);

                if (!$iItemId) {
                    throw new InvoiceException('Failed to create invoice item.', 1);
                } else {
                    $aTouchedIds[] = $iItemId;
                }
            }
        }

        //  Delete those we no longer require
        if (!empty($aTouchedIds)) {

            $oDb = Factory::service('Database');
            $oDb->where_not_in('id', $aTouchedIds);
            $oDb->where('invoice_id', $iInvoiceId);
            if (!$oDb->delete($oItemModel->getTableName())) {
                throw new InvoiceException('Failed to delete old invoice items.', 1);
            }
        }
    }
357725
public function addItem($parentId, $data)
    {
        if (empty($parentId)) {
            $this->items[0][] = $data;
        } else {
            $this->items[$parentId][] = $data;
        }
    }
759060
private void fillItem(final CmsResource resource, final CmsListItem item, final int id) {

        CmsObject cms = getCms();
        CmsXmlContent xmlContent;

        I_CmsResourceType type;
        String iconPath;

        // fill path column:
        String sitePath = cms.getSitePath(resource);
        item.set(LIST_COLUMN_PATH, sitePath);

        // fill language node existence column:
        item.set(LIST_COLUMN_PATH, sitePath);
        boolean languageNodeExists = false;
        String languageNodeHtml;

        List<Locale> sysLocales = OpenCms.getLocaleManager().getAvailableLocales();
        try {
            xmlContent = CmsXmlContentFactory.unmarshal(cms, cms.readFile(resource));
            for (Locale locale : sysLocales) {
                languageNodeExists = xmlContent.hasLocale(locale);
                if (languageNodeExists) {
                    languageNodeHtml = "<input type=\"checkbox\" checked=\"checked\" disabled=\"disabled\"/>";
                } else {
                    languageNodeHtml = "<input type=\"checkbox\" disabled=\"disabled\"/>";
                }
                item.set(locale.toString(), languageNodeHtml);

            }
        } catch (Throwable e1) {
            LOG.error(Messages.get().getBundle().key(Messages.LOG_ERR_LANGUAGECOPY_DETERMINE_LANGUAGE_NODE_1), e1);
            languageNodeHtml = "n/a";
            for (Locale locale : sysLocales) {
                item.set(locale.toString(), languageNodeHtml);
            }
        }

        // type column:
        type = OpenCms.getResourceManager().getResourceType(resource);
        item.set(LIST_COLUMN_RESOURCETYPE, type.getTypeName());

        // icon column with title property for tooltip:
        String title = "";
        try {
            CmsProperty titleProperty = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_TITLE, true);
            title = titleProperty.getValue();
        } catch (CmsException e) {
            LOG.warn(Messages.get().getBundle().key(Messages.LOG_WARN_LANGUAGECOPY_READPROP_1), e);
        }

        iconPath = getSkinUri()
            + CmsWorkplace.RES_PATH_FILETYPES
            + OpenCms.getWorkplaceManager().getExplorerTypeSetting(type.getTypeName()).getIcon();
        String iconImage;
        iconImage = "<img src=\"" + iconPath + "\" alt=\"" + type.getTypeName() + "\" title=\"" + title + "\" />";
        item.set(LIST_COLUMN_ICON, iconImage);
    }
43116
protected function _addMessage(array &$messages, array $item)
    {
        if (empty($item['ids']['singular']) && empty($item['ids']['plural'])) {
            return;
        }

        $singular = stripcslashes($item['ids']['singular']);
        $context = isset($item['context']) ? $item['context'] : null;
        $translation = $item['translated'];

        if (is_array($translation)) {
            $translation = $translation[0];
        }

        $translation = stripcslashes($translation);

        if ($context !== null && !isset($messages[$singular]['_context'][$context])) {
            $messages[$singular]['_context'][$context] = $translation;
        } elseif (!isset($messages[$singular]['_context'][''])) {
            $messages[$singular]['_context'][''] = $translation;
        }

        if (isset($item['ids']['plural'])) {
            $plurals = $item['translated'];
            // PO are by definition indexed so sort by index.
            ksort($plurals);

            // Make sure every index is filled.
            end($plurals);
            $count = key($plurals);

            // Fill missing spots with an empty string.
            $empties = array_fill(0, $count + 1, '');
            $plurals += $empties;
            ksort($plurals);

            $plurals = array_map('stripcslashes', $plurals);
            $key = stripcslashes($item['ids']['plural']);

            if ($context !== null) {
                $messages[Translator::PLURAL_PREFIX . $key]['_context'][$context] = $plurals;
            } else {
                $messages[Translator::PLURAL_PREFIX . $key]['_context'][''] = $plurals;
            }
        }
    }
590840
private function _initLanguageElements($languageSourceIds)
    {
        $languageSources = LanguageSource::findAll(['id' => $languageSourceIds]);
        foreach ($languageSources as $languageSource) {
            $this->_languageElements[$languageSource->category][$languageSource->message] = $languageSource->id;

            $category = Console::ansiFormat($languageSource->category, [Console::FG_RED]);
            $message = Console::ansiFormat($languageSource->message, [Console::FG_RED]);

            $this->_scanner->stdout('category: ' . $category . ', message: ' . $message);
        }
    }
1334099
public function setLanguageId($iLanguageId)
    {
        $iOldLang = $this->_iLanguageId;
        $this->_iLanguageId = $iLanguageId;

        // #0003777: reload content on language change
        if ($iOldLang !== null && $iOldLang != $iLanguageId) {
            try {
                $this->_setArticle($this->getProductId());
            } catch (\OxidEsales\Eshop\Core\Exception\NoArticleException $oEx) {
                \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay($oEx);
            } catch (\OxidEsales\Eshop\Core\Exception\ArticleInputException $oEx) {
                \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay($oEx);
            }
        }
    }
933993
public function loadContentTypeFieldDefinitionList($contentTypeId)
    {
        $contentType = $this->contentTypeService->loadContentType($contentTypeId, Language::ALL);

        return new Values\FieldDefinitionList(
            $contentType,
            $contentType->getFieldDefinitions()
        );
    }
637218
public function _removeIdxContentContents(array $contentUids)
    {
        if (0 < count($contentUids)) {
            $this->getEntityManager()
                    ->createQuery('DELETE FROM BackBee\ClassContent\Indexes\IdxContentContent i
                        WHERE i.content_uid IN(:content_uids)
                        OR i.subcontent_uid IN(:subcontent_uids)')
                    ->setParameters(array(
                        'content_uids' => $contentUids,
                        'subcontent_uids' => $contentUids, ))
                    ->execute();
        }

        return $this;
    }
691325
private function resolveContentEditForm(
        ContentUpdateData $contentUpdate,
        string $languageCode,
        Content $content
    ): FormInterface {
        return $this->formFactory->create(
            ContentEditType::class,
            $contentUpdate,
            [
                'languageCode' => $languageCode,
                'mainLanguageCode' => $content->contentInfo->mainLanguageCode,
                'drafts_enabled' => true,
            ]
        );
    }
435109
protected function populateLanguageIDs() {
        $this->_cache_language_ids=array();
        if($snippetLanguages=$this->snippetLanguagesIncluded()) {
            // And keep a record of parents we don't need to get
            // parents of themselves, as well as IDs to mark
            foreach($snippetLanguages as $langId) {
                $this->_cache_language_ids[$langId]=true;
            }
        }
    }