#224 Allow for setting custom ID to avoid translation clobbering #225
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.
Adds a
Translation::setId
function, with support for the Xliff extractor to call it with the Unit ID.This permits the library to better conform to xliff's uniqueness requirements (the same source text can be translated several times with different unit IDs) while still supporting PO's uniqueness requirements (the same source text cannot appear twice in the same context).
Note that this means XLIFF files converted to PO files may lose some translations that appear several times with the same source text. (This is necessary to avoid a regression of #48.)
Note that I did not modify e.g. the PO extractor to use
setId
, even though it supports round-tripping XLIFF unit IDs. These unit IDs can still be read out from the comments or using\Gettext\Genreators\Xliff::getUnitID
. (This felt like the best design choice.)Note the warnings in
Translation::setId
andTranslations::find
: Translations with custom IDs (e.g. XLIFF unit IDs) may not be found by theTranslations::find
function, as it searches using IDs generated by theTranslation::generateId
function.@oscarotero, this may break
Translation::find
for XLIFF files that were previously generated by this library, as they will use amd5
sum for the unit ID.