获取文件路径

@param string $category 分类
@param string $language 语言
@return string
342733
protected function getMessageFilePath($category, $language)
    {
        $suffix = explode('.', $category)[1];
        $messageFile = $this->basePath . "/$language/";
        if (isset($this->fileMap[$suffix])) {
            $messageFile .= $this->fileMap[$suffix];
        } else {
            $messageFile .= str_replace('\\', '/', $suffix) . '.php';
        }

        return $messageFile;
    }
86596
public function translate($category, $message, $language, $basePath)
    {
        $messages = $this->loadMessages($category, $language, $basePath);

       // Core::p($category);

        if ($language == Config::i()->getDefaultLang() && empty($messages[$message])) {
            return $message;
        } elseif (!empty($messages[$message])) {
            return $messages[$message];
        } else {
            return $message;
        }

        return false;
    }
1028665
public function getCategory($category)
    {
        $ds = DIRECTORY_SEPARATOR;
        $categoryPath = str_replace('/', $ds, $category);

        $path = app_path().$ds.'lablog'.$ds.$categoryPath;

        if (!$this->exists($category)) {
            return (object) array();
        }

        $categoryExplode = explode('/', $category);
        $categoryName = end($categoryExplode);

        $linkPrefix = \Config::get('lablog::prefix') == '/' ? '' : \Config::get('lablog::prefix');

        $baseCategory = $category;
        $categoryLink = $linkPrefix.'/category/'.$category;
        $fullCategory = $category;

        $category = new Category;
        $category->name = $categoryName;
        $category->link = $baseCategory;
        $category->url = \URL::to($categoryLink);

        return $category;
    }
563830
protected function getMessageFilePath($language)
    {
        $messageFile = $this->aliases->get($this->basePath) . '/' . $language . '/' . $this->catalog;
        if ($this->useMoFile) {
            $messageFile .= self::MO_FILE_EXT;
        } else {
            $messageFile .= self::PO_FILE_EXT;
        }

        return $messageFile;
    }
138060
public static function setLanguage($language) {
        static::$language = $language;

        static::$message = array();

        $kernalLanguageFolder = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..';
        static::addMessage($kernalLanguageFolder);

        if (defined('API_ROOT')) {
            static::addMessage(API_ROOT);
        }
    }
218036
public function fileinfo($file, $language = 'de')
    {
        if (!$file) {
            return [];
        }

        $parts = explode(';', $file);
        $fileId = $parts[0];

        $volume = $this->volumeManager->getByFileId($fileId);
        $file = $volume->findFile($fileId);

        if (!$file) {
            return [];
        }

        $attributes = $file->getAttributes();

        $info = [
            'name' => $file->getName(),
            'mimetype' => $file->getMimeType(),
            'mediaCategory' => $file->getMediaCategory(),
            'mediaType' => $file->getMediaType(),
            'size' => $file->getSize(),
            'attributes' => !empty($attributes['fileattributes']) ? $attributes['fileattributes'] : array(),
            'createdAt' => $file->getCreatedAt(),
            'modifiedAt' => $file->getModifiedAt(),
            'meta' => [],
        ];

        $metasets = $this->metaSetResolver->resolve($file);
        $meta = array();
        foreach ($metasets as $metaset) {
            $metadata = $this->metaDataManager->findByMetaSetAndFile($metaset, $file);
            $data = [];
            foreach ($metaset->getFields() as $field) {
                $value = '';
                if ($metadata) {
                    $value = $metadata->get($field->getName(), $language);
                }
                $data[$field->getName()] = $value;
            }
            $meta[$metaset->getName()] = $data;
        }

        $info['meta'] = new MetaSetAccessor($meta);

        return $info;
    }
1052459
private function getTranslations($directory, $language)
    {
        $contentJson = '';

        $directoryJson = ($language == 'en') ? '/en/' : '/../json/';

        $fileJson = $directory.$directoryJson.$language.'.json';

        if (file_exists($fileJson)) {
            $contentJson = json_decode(file_get_contents($fileJson), true);
        }

        return [
            'json'       => $contentJson,
            'auth'       => include($directory.'/'.$language.'/auth.php'),
            'pagination' => include($directory.'/'.$language.'/pagination.php'),
            'passwords'  => include($directory.'/'.$language.'/passwords.php'),
            'validation' => include($directory.'/'.$language.'/validation.php'),
        ];
    }
731989
public function findTranslated($category, $languageId)
    {
        return CategoryTranslation::whereCategoryId($category->id)
            ->whereLanguageId($languageId)
            ->first();
    }
769743
public function serialize(Category $category)
    {
        return [
            'id' => $category->getId(),
            'name' => $category->getName(),
            'order' => $category->getOrder(),
            'user' => $this->userSerializer->serialize($category->getUser()),
        ];
    }
299981
protected function loadMessagesFromDb($category, $language)
    {
        $mainQuery = new Query();
        $mainQuery->select(['t1.message message', 't2.translation translation'])
            ->from(["$this->sourceMessageTable t1", "$this->messageTable t2"])
            ->where('t1.id = t2.id AND t1.category = :category AND t2.language = :language')
            ->params([':category' => $category, ':language' => $language]);

        $fallbackLanguage = substr($language, 0, 2);
        if ($fallbackLanguage != $language) {
            $fallbackQuery = new Query();
            $fallbackQuery->select(['t1.message message', 't2.translation translation'])
                ->from(["$this->sourceMessageTable t1", "$this->messageTable t2"])
                ->where('t1.id = t2.id AND t1.category = :category AND t2.language = :fallbackLanguage')
                ->andWhere("t2.id NOT IN (SELECT id FROM $this->messageTable WHERE language = :language)")
                ->params([':category' => $category, ':language' => $language, ':fallbackLanguage' => $fallbackLanguage]);

            $mainQuery->union($fallbackQuery, true);
        }

        $messages = $mainQuery->createCommand($this->db)->queryAll();

        return ArrayHelper::map($messages, 'message', 'translation');
    }
958865
public function stripLanguage($path, $language = null)
    {
        $strip = '/' . ( isset($language) ? $language : $this->getLanguage() );

        if ( strlen($strip) > 1 && strpos($path, $strip) === 0 ) {
            $path = substr($path, strlen($strip));
        }

        return $path;
    }
683038
public function getMetadata($language)
	{
		$path = $this->getLanguagePath(ANPATH_BASE, $language);
		$file = $language.'.json';

		$meta = null;

		if (file_exists($path.DS.$file)) {
			$result = json_decode(file_get_contents($path.DS.$file));
			$meta = $result->meta;
			$meta->tag = $result->tag;
		}

		return $meta;
	}
898028
private function findOrCreateCategoryTranslation(
        CategoryInterface $category,
        CategoryWrapper $categoryWrapper,
        $locale
    ) {
        $translationEntity = $category->findTranslationByLocale($locale);
        if (!$translationEntity) {
            $translationEntity = $this->categoryTranslationRepository->createNew();
            $translationEntity->setLocale($locale);
            $categoryWrapper->setTranslation($translationEntity);
        }

        return $translationEntity;
    }
506160
public function getTree($lang = null) {
		if (is_null($lang)) $lang = $this->_language;

		$file = $this->_language_path . $lang . '/tree.php';
		return $this->_loadFile($file);
	}
559746
private function generateContentTranslation(Language $language)
    {
        $faker = Factory::create($language->i18n);
        return [
            'teaser'          => '<p>' . $faker->realText(300) . '</p>',
            'body'            => $this->generateBodyHTML($faker),
            'seo_title'       => $faker->realText(60, 1),
            'seo_description' => $faker->realText(160, 1)
        ];
    }
1370318
private function setCategoryFullSlug(Category $category): void
    {
        static $languages;

        if (! $languages) {
            $languages = $this->language ? [$this->language] : TransHelper::getAllLanguages();
        }

        foreach ($languages as $language) {
            $category->translations()->where('locale', $language->iso_code)->update([
                'full_slug' => $this->getSlugForCategory($category->id, $language->iso_code),
            ]);
        }

        foreach ($category->descendants()->get() as $descendant) {
            foreach ($languages as $language) {
                $descendant->translations()->where('locale', $language->iso_code)->update([
                    'full_slug' => $this->getSlugForCategory($descendant->id, $language->iso_code),
                ]);
            }
        }
    }
936235
function createCategories() {
    $cnt = count( $this->categories );
    if( 0 >= $cnt )
      return;
    $output = null;
    foreach( $this->categories as $category ) {
      $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' ));
      if( is_array( $category['value'] )) {
        foreach( $category['value'] as $cix => $categoryPart )
          $category['value'][$cix] = $this->_strrep( $categoryPart );
        $content  = implode( ',', $category['value'] );
      }
      else
        $content  = $this->_strrep( $category['value'] );
      $output    .= $this->_createElement( 'CATEGORIES', $attributes, $content );
    }
    return $output;
  }