Skip to content
This repository was archived by the owner on Jul 2, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions generate_translate_template.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

$case1 = $(Get-ChildItem -r -i *.js | Select-String "i18n\(`"([^`"]*?)`"\)" -AllMatches | ForEach-Object -Process {$_.Matches[0].Groups[1].Value})
$case2 = $(Get-ChildItem -r -i *.js | Select-String "i18n\(`'([^`']*?)`'\)" -AllMatches | ForEach-Object -Process {$_.Matches[0].Groups[1].Value})
$all_case = $case1 + $case2

$key_pairs = $( $all_case |Sort-Object -Unique -CaseSensitive|ForEach-Object -Process {$x = $_ -replace "`"","\`""; "`n`"{0}`":`"{0}`"" -f $x})

$all_str = $key_pairs -join ','

"translation=
{$all_str
};" | Out-File -FilePath translation_template.js_temp


13 changes: 11 additions & 2 deletions src/PartKeepr/FrontendBundle/Resources/public/js/Util/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
* @param string
* @return {*}
*/

function i18n (string) {
return string;
}
if(string in translation)
{
return translation[string];
}
else
{
return string;
}

}
Loading