From 1eab0868875d2ffe6c0a00814c63525f92f50f06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Dobro=C5=88?= Date: Sun, 10 Jul 2022 23:20:27 +0200 Subject: [PATCH] Fill phrase tokens/types to generated translations --- src/fbt/Services/TranslationsGeneratorService.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/fbt/Services/TranslationsGeneratorService.php b/src/fbt/Services/TranslationsGeneratorService.php index 09ab030..41503d1 100644 --- a/src/fbt/Services/TranslationsGeneratorService.php +++ b/src/fbt/Services/TranslationsGeneratorService.php @@ -168,11 +168,14 @@ public function generateTranslations(string $source, $translationsPath, $inputPa $sourceStrings = json_decode(file_get_contents($source), true); $phrases = $sourceStrings['phrases']; - $hashToTexts = array_column($phrases, 'hashToText'); $translations = []; - foreach ($hashToTexts as $hashToTextGroups) { - foreach ($hashToTextGroups as $hash => $text) { + foreach ($phrases as $phrase) { + $metadata = $phrase['jsfbt']['m'] ?? []; + + $tokens = array_column($metadata, "token"); + $types = array_column($metadata, "type"); + foreach ($phrase['hashToText'] as $hash => $text) { $translations[$hash] = [ 'translations' => [ [ @@ -180,8 +183,8 @@ public function generateTranslations(string $source, $translationsPath, $inputPa 'variations' => [], ], ], - 'tokens' => [], - 'types' => [], + 'tokens' => $tokens, + 'types' => array_map("fbt\Transform\FbtTransform\Translate\FbtSiteMetaEntry::getVariationMaskFromType", $types), ]; } }