Add option to identify the source library when merging strings.xml files #351
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This improves the existing
an_localize_libs
action to adds support for thesource_id
option.This option aims to helps identify which library each
<string>
merged into the mainstrings.xml
came from.Why
strings.xml
in a later version would properly be removed from the app'sstrings.xml
, instead of being kept in the apps'strings.xml
forever while not being used nor useful anymorean_localize_libs
's helper code, and also might require a deeper analysis of potential consequences before going that route (e.g. what if a string is deleted from a lib later… but that key was still used by the app itself too?). Still, adding an attribute to identify the libs the strings were coming from still felt a useful first step anywaystrings.xml
is coming fromWordPress/src/main/res/strings.xml
, where the source of truth for that string actually comes from (the app, or a lib?) and thus where to change that value if they need to (no point in changing the copy in the app'sstrings.xml
file if the key will be re-overwritten by the next lib merge!)content_override
if they do want the key from the app'sstrings.xml
to always take over and not be replace by the same key from a lib in the future (useful for example from a key likeapp_name
not to be overwritten by a merge of the about library if it were to define one as well…)How
The action now accepts a new key in the
Hash
passed to itslibs_strings_path
parameter.That new key is named
source_id
and allows the caller to provide an (optional) "identifier" string for the library. If provided, that identifier will be added as the value of a customa8c-src-lib
attribute of the<string …>
XML nodes added or updated during the merging of the strings of said library.You can see the result in action in this draft WPAndroid PR.
This PR also takes the occasion to:
nil
value for theexclusions
key in the HashUI.message
andUI.verbose
instead ofputs
when the helper printed information about the strings being merged or updated.