Open st3fan opened 7 years ago
Hello @st3fan, Sounds like an interesting case that i never have dealt with. Xcode project format doesn't have an official spec, so the way pbxproj has been built is by reverse engineering the format. What i usually do when a new case appear is the following:
Based on that sequence, i can determine what new sections were created and how they are linked to one another.
The PBXVariantGroup
it's not defined and probably will have some special logic that have to be dealt with.
I'm more than happy to do this for you guys if you send over the project.pbxproj after the changes have been done manually. :)
Awesome. We really appreciate the help.
This is what I did:
xcodebuild -importLocalizations -localizationPath focusios-l10n/it/focus-ios.xliff -project Blockzilla.xcodeproj
Attached are the projects files before and after. The -importLocalizations
did not result in any project changes. Just the files being updated.
Git status:
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: Blockzilla/it.lproj/InfoPlist.strings
new file: Blockzilla/it.lproj/Localizable.strings
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Blockzilla.xcodeproj/project.pbxproj
modified: Blockzilla/it.lproj/InfoPlist.strings
modified: Blockzilla/it.lproj/Localizable.strings
Untracked files:
(use "git add <file>..." to include in what will be committed)
ContentBlocker/it.lproj/
XCUITest/it.lproj/
Diff of the project file:
diff -Bub ~/Desktop/Focus1BeforeAddingLocale.pbxproj ~/Desktop/Focus2AfterAddingLocale.pbxproj
--- /Users/sarentz/Desktop/Focus1BeforeAddingLocale.pbxproj 2017-01-09 12:59:01.000000000 -0500
+++ /Users/sarentz/Desktop/Focus2AfterAddingLocale.pbxproj 2017-01-09 13:00:06.000000000 -0500
@@ -241,6 +241,8 @@
E47F9AE91DB9329D00A93285 /* Adjust-Focus.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Adjust-Focus.plist"; sourceTree = "<group>"; };
E47F9AEB1DB9333200A93285 /* Adjust-Klar.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Adjust-Klar.plist"; sourceTree = "<group>"; };
E47F9AED1DB9338600A93285 /* AdjustIntegration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdjustIntegration.swift; sourceTree = "<group>"; };
+ E4BCCD041E24071800BBAAA7 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ E4BCCD051E24071800BBAAA7 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Localizable.strings; sourceTree = "<group>"; };
E4BF2DD31BACE8CA00DA9D68 /* Klar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; name = Klar.app; path = "Firefox Klar.app"; sourceTree = BUILT_PRODUCTS_DIR; };
E4BF2DD61BACE8CA00DA9D68 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
E4BF2DDD1BACE8CA00DA9D68 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -603,6 +605,7 @@
en,
Base,
de,
+ it,
);
mainGroup = E4BF2DCA1BACE8CA00DA9D68;
productRefGroup = E4BF2DD41BACE8CA00DA9D68 /* Products */;
@@ -807,6 +810,7 @@
children = (
D343DCC31C44356500D7EEE8 /* de */,
D362D26A1C47326A0041980A /* en */,
+ E4BCCD051E24071800BBAAA7 /* it */,
);
name = Localizable.strings;
sourceTree = "<group>";
@@ -832,6 +836,7 @@
children = (
E40AFC791DDDE98300DA5651 /* en */,
D3C70C671DDE795300CEE458 /* de */,
+ E4BCCD041E24071800BBAAA7 /* it */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
Zip file containing both project files:
Thanks for the files, i took a look at the way Xcode imports the files, and i saw some funny behaviors when importing the .xliff file with the Editor > Import localization menu.
Note to self: so far, this is what i manage to gather:
I will try to tackle this this week/weekend.
@st3fan i have some proposed changes #116 , can you verify it works for what you need?
PBXVariantGroup
Is this feature done or included in current stable build
(I know this is not really a bug report, but I don't know where else to ask questions - I'm happy to convert this into a wiki page as an example usage though)
Hello and thank you for maintaining this project. At Mozilla we are trying to use this for the following use case:
We have a product called Focus at https://github.com/mozilla-mobile/focus which currently is English only.
We localize the product by exporting an
en.XLIFF
file to our localization volunteers and we get back XLIFF files for other locales. To import these we runxcodebuild -importLocalizations -localizationPath l10n/nl.xliff
for example. This spits out .strings files in the proper .lproj directories.The problem is that
xcodebuild
only generates the files. It does not actually add them to the project.This is where
pbxproj
comes in. I'd like to use it to find for example thePBXVariantGroup
forLocalizable.strings
and then add aPBXFileReference
reference forit.lproj/Localizable.strings
to it.However, we are lost in the complexity of both the Xcode projects and the pbxproj API.
My question to you is if we can get some help to find out how to do this. I'm happy to turn the end result in some reusable code that anyoen can use. Or a blog post or a wiki page.
🧀