Skip to content

Commit

Permalink
Add InfoPlist.xcstrings to the list of dashboard configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
MalekKamel committed Oct 17, 2024
1 parent a3205c4 commit 4cd3453
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions solara/lib/core/dashboard/handler/base_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def handle_error(res, error, message, status = 500)
res.status = status
res.body = JSON.generate({ success: false, error: "#{message}: #{error.message}" })
res.content_type = 'application/json'
Solara.logger.error(error)
end

def method_not_allowed(res)
Expand Down
6 changes: 1 addition & 5 deletions solara/lib/core/dashboard/handler/edit_section_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ def update_section(key, data, brand_key)
path = template[:path]

if File.exist?(path)
if key === 'InfoPlist.xcstrings'
InfoPListStringCatalogManager.new(FilePath.brand_infoplist_string_catalog(brand_key)).update(data)
else
File.write(path, JSON.pretty_generate(data))
end
File.write(path, JSON.pretty_generate(data))
Solara.logger.debug("Updated Config for #{path}: #{data}")
else
raise "Config file not found: #{path}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@

module StringCatalogUtils
def load_string_catalog(path)
@path = path
JSON.parse(File.read(path))
end

def get_value(data, key, target, language)
lang = language || data['sourceLanguage']
data['strings'][key]['localizations'][lang]['stringUnit'][target]
localizations = data.dig('strings', key, 'localizations', lang)

unless localizations && localizations['stringUnit']
error_message = "The default language is #{lang}, but no localizations are available for key '#{key}'. Please address this issue in {@path}. You can easily open the file in Xcode to make the necessary adjustments."
Solara.logger.fatal(error_message)
exit 1
end

string_unit = localizations['stringUnit']
string_unit[target]
end

def has_value?(data, key, language)
Expand Down
6 changes: 6 additions & 0 deletions solara/lib/core/template/configurations.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
"name": "iOS Signing",
"filePath": "ios/ios_signing.json",
"url": "https://raw.githubusercontent.com/Solara-Kit/Solara/refs/heads/develop/solara/lib/core/template/brands/ios/ios_signing.json"
},
{
"key": "InfoPlist.xcstrings",
"name": "InfoPlist.xcstrings",
"filePath": "ios/InfoPlist.xcstrings",
"url": "https://raw.githubusercontent.com/Solara-Kit/Solara/refs/heads/develop/solara/lib/core/template/brands/ios/InfoPlist.xcstrings"
}
]
}

0 comments on commit 4cd3453

Please sign in to comment.