Until you get a language translated it might be better to have english rather than blank labels. This class fills blank labels with text from another label language in the same label module.
First we create a class declaration and a simple main method where you can select languages and if you want to copy in one or both directions wherever a blank label is encountered.
class LabelAdjustments { } public static void main(Args _args) { LabelAdjustments labelAdjustment = new LabelAdjustments(); Dialog dialog = new Dialog("Fill empty labels"); DialogField dfLanguageFrom, dfLanguageTo; DialogField dfBothDirections; dfLanguageFrom = dialog.addField(extendedTypeStr(LanguageId), "Originating language"); dfLanguageTo = dialog.addField(extendedTypeStr(LanguageId), "Target language"); dfBothDirections = dialog.addField(extendedTypeStr(NoYesId), "Copy both directions"); if (dialog.run()) { if (dfBothDirections.value()) { labelAdjustment.fillBlanksBothDirections(dfLanguageFrom.value(), dfLanguageTo.value()); } else { labelAdjustment.fillBlankLabelsFrom(dfLanguageFrom.value(), dfLanguageTo.value()); } } }
Then the method to handle if bidirectional copy is chosen. We simply call the languages one at a time to save some coding and simplifies by traversing one at a time.
public void fillBlanksBothDirections(LanguageId _first, LanguageId _second) { this.fillBlankLabelsFrom(_first, _second); this.fillBlankLabelsFrom(_second, _first); }
Then the actual code which does the copying of label text and comment.
public void fillBlankLabelsFrom(LanguageId _from, LanguageId _to) { str labelFileId = 'XXX'; // the label id int i; str comment, labelText; SysLabel sysLabel = new SysLabel(_from); SysLabelEdit sysLabelEdit = new SysLabelEdit(); // iterate all labels in reference file for (i = sysLabel.maxLabelId(labelFileId); i >= 0; i--) { // check if label text exists in target label if (strLen(sysLabel::labelId2String(strFmt("@%1%2", labelFileId, i), _to)) == 0) { if (strLen(sysLabel::labelId2String(strFmt("@%1%2", labelFileId, i), _from)) == 0) { error(strFmt('No label text was found for either language for @%1%2', labelFileId, i)); } else { labeltext = sysLabel.extractString(strFmt("@%1%2", labelFileId, i)); comment = sysLabel.extractComment(strFmt("@%1%2", labelFileId, i)); sysLabelEdit.labelModify(_to, strFmt("@%1%2", labelFileId, i), labelText, comment, SysLabelApplModule::None); } } } Label::flush(labelFileId, _to); }