BartyCrouch
BartyCrouch copied to clipboard
Localizable.strings updated with new keys, but the values still empty
Hi @Dschee , last month, I used BartyCrouch without any problems. After some time and BartyCrouch installation updated I'm back to translating new strings. But now a new problem arises, the new keys are generated but with empty values.
It's seems the values from line is not saved to .strings files, only the keys:
self.noResultTitleLabel.text = BartyCrouch.translate(key: "search_no_result_title", translations: [.indonesia: "Hasil tidak ditemukan", .english: "Result not found"])
I'm not sure what is going on
Me neither, probably a bug in the recent changes. Will have a look soon alongside some other issues and hopefully fix. Could you please post your config file contents just in case I can't reproduce this issue? Thanks!
here's my .toml
config:
[update]
tasks = ["code", "transform", "normalize"]
[update.interfaces]
path = "."
defaultToBase = false
ignoreEmptyStrings = false
unstripped = false
[update.code]
codePath = "."
localizablePath = "."
defaultToKeys = false
additive = true
unstripped = false
[update.transform]
codePath = "."
localizablePath = "."
transformer = "swiftgenStructured"
supportedLanguageEnumPath = "."
typeName = "BartyCrouch"
translateMethodName = "translate"
[update.normalize]
path = "."
sourceLocale = "id"
harmonizeWithSource = true
sortByKeys = true
[lint]
path = "."
duplicateKeys = true
emptyValues = true
Thanks. Could you also please post your BartyCrouch.swift file and it's directory path? Did you already try setting the path
parameters to more detailed paths like recommended in the README? Also, are you sure your enum cases in BartyCrouch.swift are indonesia
and not indonesian
(note tha n
at the end)? Just trying to help ...
I jus ttested this configuration and it's working on my machine ...
Here's my BartyCrouch.swift
import Foundation
enum BartyCrouch {
enum SupportedLanguage: String {
// TODO: remove unsupported languages from the following cases list & add any missing languages
case english = "en"
case indonesia = "id"
}
static func translate(key: String, translations: [SupportedLanguage: String], comment: String? = nil) -> String {
let typeName = String(describing: BartyCrouch.self)
let methodName = #function
print(
"Warning: [BartyCrouch]",
"Untransformed \(typeName).\(methodName) method call found with key '\(key)' and base translations '\(translations)'.",
"Please ensure that BartyCrouch is installed and configured correctly."
)
// fall back in case something goes wrong with BartyCrouch transformation
return "BC: TRANSFORMATION FAILED!"
}
}
@Dschee , I've tried to debug the source code.
I think the error is related with the recent changes at SupportedLanguagesReader
It seems the incorrect enum
from another location was considered as SupportedLanguage
enum by SupportedLanguagesReader
Here's the incorrect enum
that stored into caseToLangCode[langCase]
:
enum ExampleEnum: String, CaseIterable {
case custom = "custom"
case discount = "discount"
case voucher = "voucher"
}
I already make sure that the .toml
config is correct
Hello, I have the same issue. Is anyone working on it?
@MSlaski As I don't have much time, to fix this, I'd need a Demo project (with code and config) where this can be reproduced. This way it will be much easier for me (or someone else) to fix.
@MSlaski @deden, @alphatroya found a solution on issue #133 which help me fix the empty string issue. Can you please try?
" I've updated supportedLanguageEnumPath
parameter for the update.transform
action and problem have gone. "
Basically you need to make sure the supportedLanguageEnumPath
param takes you to the BartyCrouch file with the languages enum.