Skip to content

Commit

Permalink
Fill phrase tokens/types to generated translations
Browse files Browse the repository at this point in the history
  • Loading branch information
richardDobron committed Jul 10, 2022
1 parent 192b453 commit 5391533
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/fbt/Services/TranslationsGeneratorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,23 @@ 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' => [
[
'translation' => '',
'variations' => [],
],
],
'tokens' => [],
'types' => [],
'tokens' => $tokens,
'types' => array_map("fbt\Transform\FbtTransform\Translate\FbtSiteMetaEntry::getVariationMaskFromType", $types),
];
}
}
Expand Down

0 comments on commit 5391533

Please sign in to comment.