Skip to content

Conversation

@Tantalum73
Copy link

This PR introduces a build setting BUILD_ONLY_KNOWN_LOCALIZATIONS. Only languages explicitly added to the project's "Localizations" will be built when set.
The new build setting allows developers to have work-in-progress translations in their project, which don't get built.

In the old world with only .strings files, it was possible to have partial translations in files that were on disk, but not referenced in the Xcode project. When localization was complete, they were simply added as a reference, and then they started contributing to the build.
Since String Catalogs contain all localizations in a single file, it was not possible to not build content for a given language, making this workflow more complicated to achieve.

This build setting fixes that. When set, only languages in the list of "Localizations" in the project settings are built – including String Catalog content.

Now, for the time that a new language is brought up that isn't fully translated yet, developers enable BUILD_ONLY_KNOWN_LOCALIZATIONS, and remove that language from the list of Localizations. The work on this language can continue, and when it's ready to ship they add it back to the list, or disable BUILD_ONLY_KNOWN_LOCALIZATIONS.

… languages added to Localizations in the project when set

knownLocalizations.removeAll(where: { $0 == "Base" })
if !knownLocalizations.isEmpty {
delegate.note("XCStrings will compile languages for known regions: \(knownLocalizations.joined(separator: ", "))")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just heads up that messages like this are going to show up for every xcstrings file, although in this particular case the specific file is not provided. Not saying it needs to be provided, but may appear as duplicate messages. Also for IB Compiler, etc.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the changes in 9764b31 where a source location added to the message, they might look like duplicates at first, but double clicking the entry will open the corresponding source file.
Thanks for pointing that out!

}

// This region is not supported, so it shouldn't build.
delegate?.note("Skipping .lproj directory '\(regionVariantName).lproj' because '\(regionVariantName)' is not in project's known localizations (BUILD_ONLY_KNOWN_LOCALIZATIONS is enabled)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to look into specifying file paths for diagnostics like this. I don't mean in the message, but rather as part of the diag instance.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! By doing this, a double click on the log message will automatically open the source file, neat!

9764b31

return true
}

if regionVariantName == "mul" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if it is Base?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base will be included in the list of known languages if using Base internationalization. I think no special rules need to apply to Base here.

@matthewseaman
Copy link
Contributor

@swift-ci test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants