-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
85 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
solara/lib/core/dashboard/brand/InfoPlistStringCatalogManager.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class InfoPlistStringCatalogManager { | ||
constructor(jsonData) { | ||
this.data = jsonData; | ||
this.localizations = {}; | ||
this.extractLocalizations(); | ||
} | ||
|
||
extractLocalizations() { | ||
for (const [key, details] of Object.entries(this.data.strings)) { | ||
for (const [lang, localization] of Object.entries(details.localizations)) { | ||
const formattedKey = `${key}.${lang}`; | ||
this.localizations[formattedKey] = localization.stringUnit.value; | ||
} | ||
} | ||
return this.localizations | ||
} | ||
} | ||
|
||
export default InfoPlistStringCatalogManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
solara/lib/core/scripts/platform/ios/infoplist_string_catalog_manager.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
class InfoPListStringCatalogManager | ||
|
||
def update(result, path) | ||
localizations = JSON.parse(File.read(path)) | ||
|
||
result.each do |base_key, languages| | ||
# Ensure the base key exists in the localizations | ||
if localizations['strings'].key?(base_key) | ||
# Update each language value | ||
languages.each do |lang_code, value| | ||
# Initialize the localizations for the language if it doesn't exist | ||
localizations['strings'][base_key]['localizations'][lang_code] ||= { | ||
"stringUnit" => { | ||
"state" => "new", | ||
"value" => "" | ||
} | ||
} | ||
# Update the value in the JSON structure | ||
localizations['strings'][base_key]['localizations'][lang_code]['stringUnit']['value'] = value | ||
end | ||
end | ||
end | ||
|
||
# Remove any localization keys that are no longer in the result | ||
localizations['strings'].each do |base_key, data| | ||
data['localizations'].each_key do |lang_code| | ||
unless result.key?(base_key) && result[base_key].key?(lang_code) | ||
data['localizations'].delete(lang_code) | ||
end | ||
end | ||
end | ||
|
||
File.write(path, JSON.pretty_generate(localizations)) | ||
end | ||
|
||
end |