i18n: re-render visible dynamic views on language switch
translatePage() only rewrites static [data-l10n] elements, so labels built at render time (Check card/Edit/Export/Delete, Open, Remove, Send, ...) stayed in the old language. toggleLang() now calls refreshDynamicI18n(), which re-renders only the visible dynamic views: - profiler sub-tab: current view (list, snapshot list, editor, results via the new profilerRenderResultsView with profilerResults stored, snapshot via profilerRenderSnapshotData which leaves the name input alone) - open scan modal: profilerScanRefreshOptions re-translates the mask labels without touching checkbox state - cards table (cardsRender), proactive events/log/PLI (async, only when the sub-tab is visible) Also removed the duplicated translatePage() call in toggleLang. New test for profilerScanRefreshOptions. SW cache v83 -> v84.
This commit is contained in:
@@ -21,13 +21,14 @@ function extractFunc(src, name, asyncFn) {
|
||||
return (asyncFn ? 'async ' : '') + src.slice(m.index, i + 1);
|
||||
}
|
||||
|
||||
const FNS = ['profilerNormHex', 'profilerNormHexStrict', 'profilerMatch', 'profilerMatchMin', 'profilerMaskPrefix4', 'profilerFileFields', 'profilerContentKindForFileType', 'profilerEmptyRecordContent', 'profilerValidateProfile', 'profilerCustomNameForPath', 'profilerUpdateRulePath', 'profilerResultAspects', 'profilerAspectSummary', 'profilerNumRanges', 'esc', 'escHtml', 'profilerRawDataCheck', 'profilerRenderReport', 'parseBerLen', 'parseTlvList', 'fcpInt', 'fcpParseTlvs', 'fcpFileDescriptor', 'fcpLifeCycle', 'fcpSfi', 'fcpDo', 'fcpDecode', 'fcpDiffHtml', 'profilerFciPreviewItems', 'profilerUpdateFciPreview', 'profilerUpdateRule', 'profilerFciInput', 'profilerScanToggleAll', 'profilerScanIgnoreAllState', 'swapNibbles', 'decIccid', 'profilerSnapshotIccid', 'profilerValidateSnapshot', 'profilerListSwitch'];
|
||||
const FNS = ['profilerNormHex', 'profilerNormHexStrict', 'profilerMatch', 'profilerMatchMin', 'profilerMaskPrefix4', 'profilerFileFields', 'profilerContentKindForFileType', 'profilerEmptyRecordContent', 'profilerValidateProfile', 'profilerCustomNameForPath', 'profilerUpdateRulePath', 'profilerResultAspects', 'profilerAspectSummary', 'profilerNumRanges', 'esc', 'escHtml', 'profilerRawDataCheck', 'profilerRenderReport', 'parseBerLen', 'parseTlvList', 'fcpInt', 'fcpParseTlvs', 'fcpFileDescriptor', 'fcpLifeCycle', 'fcpSfi', 'fcpDo', 'fcpDecode', 'fcpDiffHtml', 'profilerFciPreviewItems', 'profilerUpdateFciPreview', 'profilerUpdateRule', 'profilerFciInput', 'profilerScanToggleAll', 'profilerScanIgnoreAllState', 'swapNibbles', 'decIccid', 'profilerSnapshotIccid', 'profilerValidateSnapshot', 'profilerListSwitch', 'profilerScanRefreshOptions'];
|
||||
let code = '';
|
||||
for (const f of FNS) code += extractFunc(html, f) + '\n';
|
||||
code += extractFunc(html, 'profilerBuildFileRule', true) + '\n';
|
||||
code += extractFunc(html, 'profilerRunRule', true) + '\n';
|
||||
code += extractFunc(html, 'profilerScanCard', true) + '\n';
|
||||
code += extractFunc(html, 'profilerBuildSnapshotFile', true) + '\n';
|
||||
code += "var _scanTarget = 'profile';\n";
|
||||
code += html.match(/const PROFILER_MASK_PREFIX4_FIDS = \{[\s\S]*?\n\};/)[0] + '\n';
|
||||
eval(code);
|
||||
|
||||
@@ -942,3 +943,21 @@ test('profilerListSwitch toggles the profiles/snapshots tabs', () => {
|
||||
|
||||
delete global.document;
|
||||
});
|
||||
|
||||
test('profilerScanRefreshOptions re-translates mask labels without touching checkbox state', () => {
|
||||
global.t = s => (s === 'Match first 4 bytes for' ? 'FIRST4' : s);
|
||||
const span = { textContent: '' };
|
||||
const cb = {
|
||||
checked: true,
|
||||
parentElement: { querySelector: sel => (sel === 'span' ? span : null) },
|
||||
getAttribute: () => '6F07',
|
||||
};
|
||||
global.document = {
|
||||
querySelectorAll: sel => (sel === '#profiler-scan-mask input[data-mask-fid]' ? [cb] : []),
|
||||
};
|
||||
profilerScanRefreshOptions();
|
||||
assert.strictEqual(span.textContent, 'FIRST4 EF.IMSI');
|
||||
assert.strictEqual(cb.checked, true);
|
||||
delete global.document;
|
||||
delete global.t;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user