Comments (6)
@Jeehut Ok now I got you. My final solution is that I added the en
local version of the InfoPlist.strings
file.
from bartycrouch.
@patricks Thank you for bringing this up. You are right that we are no longer ignoring strings files names InfoPlist.strings
(there was never a reason to do that, it was introduced accidentally due to a misunderstanding) since version 4.9.0
. This might be the reason you see this happen just now. But generally there can only be 2 reasons for keys being removed:
- The BartyCrouch Strings file parsers Regex doesn't recognize the key in the Strings file when reading it, so it disappears when writing during an update. A common reason for this in
InfoPlist.strings
files seems to be that some people don't have their keys surrounded by quotes, see also my comment here. - You have configured BartyCrouch to run the
normalize
task at the top of your config file (on by default) and you have theharmonizeWithSource
option set totrue
in your config filesnormalize
section. Then BartyCrouch will make sure that all languages have the same keys as your source language, so it will add all missing keys and remove all that are not available in the source language. To turn this behavior off, you can just setharmonizeWithSource
tofalse
in your config file, like this:
[update.normalize]
paths = ["."]
subpathsToIgnore = [".git", "carthage", "pods", "build", ".build", "docs"]
sourceLocale = "en"
harmonizeWithSource = false
sortByKeys = true
Does this help? If not, please provide an example InfoPlist.strings
file with that key so I can better understand. Maybe this key needs special handling in some way? But if it's just a normal key like any other, see my two points above.
from bartycrouch.
@Jeehut I think this key needs some handling, because there basic keys are listed in the Info.plist itself.
Since iOS 14 there is this temporary location usage feature available. To inform the user why the app requires a location now you can set special info texts per use case. These keys are defined in the Info.plist as dictionary.
For details see:
NSLocationTemporaryUsageDescriptionDictionary
These keys have to be translated in the InfoPlist.strings
files.
"friends" = "Eine Position wird benötigt um Freunde zu finden";
"coffee" = "Eine Position wird benötigt um Kaffeehäuser in der Umgebung zu finden";
Tuning off harmonizeWithSource
wouldn't be a really good workaround for use, because we use this feature to cleanup our translation files.
from bartycrouch.
@patricks Thank you for the additional info. But from the documentation it's still not clear to me how the Stings file might look like. Could you please provide an example (you can redact the exact translations if needed), so I can reproduce and fix? Thank you!
from bartycrouch.
@Jeehut the InfosPlists.strings
file looks exactly as the code provided above:
"friends" = "Eine Position wird benötigt um Freunde zu finden";
And here is the InfoPlist
file (cut):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSLocationTemporaryUsageDescriptionDictionary</key>
<dict>
<key>friends</key>
<string>A position is required to find your friends</string>
</dict>
</dict>
</plist>
from bartycrouch.
@patricks I see, so that was already the entries in the InfoPlist.strings
file, I thought there was some kind of dictionary structure in the strings file that we have to support, such as:
"NSLocationTemporaryUsageDescriptionDictionary" = {
"friends" = "Eine Position wird benötigt um Freunde zu finden";
"coffee" = "Eine Position wird benötigt um Kaffeehäuser in der Umgebung zu finden";
}
😅
But it looks like the entries in your Strings file are plain old "normal" keys, so no new structure needed. When I put the Strings content you shared into a Regex checker, it perfectly matches the Regex used in BartyCrouch:
So, case 1 I mentioned in my comment above shouldn't be the reason why it gets deleted. This leaves us with case 2. If I understand your use case correctly, what you want is:
- Use the
normalize
task including theharmonizeWithSource
option set totrue
andsourceLocale
set toen
for most of your Strings files. - For the
Info.plist
file only, you don't have a localeen
and thus the keys get deleted in your other translations, too. What you want is a way to set a differentsourceLocale
for just theInfoPlist.strings
files OR to turn offharmonizeWithSource
only for theInfoPlit.strings
file.
Thankfully, this should be possible already. What you need to do is:
- Keep your default settings in your root level
.bartycrouch.toml
file, but add"InfoPlist.strings"
to yoursubPathToIgnore
so they don't get updated when you run thebartycrouch update
comment on the root path. - Add a new
.bartycrouch.toml
file to the subpath you are ignoring in the root file now, but here, change the configuration (both thepaths
need to be updated and also thesourceLocale
changed to a language you actually have a Strings file for OR theharmonizeWithSource
option set tofalse
). - (If you use the build-script) Update the build-script to not only run
bartycrouch update -x
andbartycrouch lint -x
, but add a third call tobartycrouch update -x -p /your/subpath
and a fourth tobartycrouch lint -x -p /your/subpath
. (You might need to extract theInfoPlist.strings
file into its own parent folder in case it shared the same with others, e.g. toSupportingFiles
.)
Please note also that a much simpler solution would be if you just added the en
locale version to your InfoPlist.strings
file, then you don't need to create a second configuration file at all.
Please tell me if this works or provide more context (e.g. your full .bartycrouch.toml
contents) so I can better understand the problem.
from bartycrouch.
Related Issues (20)
- Can't build project after upgrade bartycrouch to 4.8.0
- Explicit folders on the `codePaths` argument shouldn't be ignored later. HOT 5
- Cocoapods executable doesn't work on x86 machines HOT 19
- Embed lib_InternalSwiftSyntaxParser.dylib into package HOT 3
- error: the target 'SwiftSyntax' in product 'SwiftSyntax' contains unsafe build flags HOT 4
- Support for none default Xcode install path HOT 1
- Add new line on every translation after normalize HOT 2
- Translate successful but no output for Storyboards Main.string file HOT 3
- BartyCrouch with SwiftGen creates empty string values HOT 2
- [Feat] Autogenerate `.strings` files HOT 3
- `overrideComments` option doesn't work HOT 4
- [Bug] CI failed for version 4.12.0 HOT 2
- [Bug] update.code with additive=false and code in multiple parent directories looses strings HOT 5
- [Feat] Tip: How to localize LocalizedStringResource types with bartycrouch HOT 3
- [Feat] Support for modular application HOT 4
- [Bug] Translation Microya.ApiError<Microya.EmptyBodyResponse> error 3 HOT 2
- [Bug] PodSpec does not support iOS anymore HOT 7
- [Feat] Extract localizable Strings from SwiftUI Text HOT 1
- [Question/Bug] : .bartycrouch.toml permission errors on dependent test build HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bartycrouch.