Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

Commit 62773b7

Browse files
KONFeatureclaude
andcommitted
feat: add live preview of i18n translations in advanced config
- Added real-time updates of i18n object when translation fields change - Collected i18n values from input fields dynamically - Updated logo URL replacement to handle let declaration format - Added input event handlers for all i18n translation fields Users now see their custom translations immediately reflected in the advanced configuration textarea. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ba000a9 commit 62773b7

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

admin/js/admin.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,26 @@ jQuery(document).ready(function($) {
2727
var modalLang = $('#frak_modal_language').val();
2828
var currentConfig = editor.codemirror.getValue();
2929

30+
// Collect i18n values
31+
var i18nValues = {};
32+
$('.frak-i18n-table input').each(function() {
33+
var $input = $(this);
34+
var key = $input.attr('name').replace('frak_modal_i18n[', '').replace(']', '');
35+
var value = $input.val();
36+
if (value) {
37+
i18nValues[key] = value;
38+
}
39+
});
40+
3041
// Update app name
3142
currentConfig = currentConfig.replace(
3243
/(metadata:\s*{\s*name:\s*")[^"]*(")/,
3344
'$1' + appName + '$2'
3445
);
3546

36-
// Update logo URL
47+
// Update logo URL - both in let declaration and in objects
3748
currentConfig = currentConfig.replace(
38-
/(logoUrl:\s*")[^"]*(")/,
49+
/(let logoUrl = ')[^']*(')/,
3950
'$1' + logoUrl + '$2'
4051
);
4152

@@ -54,6 +65,18 @@ jQuery(document).ready(function($) {
5465
);
5566
}
5667

68+
// Update i18n object
69+
var i18nJson = JSON.stringify(i18nValues, null, 0);
70+
// Find the i18n parsing section and update it
71+
var i18nMatch = currentConfig.match(/let i18n = {};\s*try {[\s\S]*?} catch/);
72+
if (i18nMatch) {
73+
// Replace the entire i18n section
74+
var newI18nSection = "let i18n = {};\ntry {\n i18n = JSON.parse('" +
75+
i18nJson.replace(/'/g, "\\'") +
76+
"'.replace(\n /&amp;|&lt;|&gt;|&#39;|&quot;/g,\n tag =>\n ({\n '&amp;': '&',\n '&lt;': '<',\n '&gt;': '>',\n '&#39;': \"'\",\n '&quot;': '"'\n }[tag] || tag)\n )) || {};\n} catch";
77+
currentConfig = currentConfig.replace(/let i18n = {};\s*try {[\s\S]*?} catch/, newI18nSection);
78+
}
79+
5780
// Update floating button position
5881
currentConfig = currentConfig.replace(
5982
/(modalWalletConfig:\s*{[\s\S]*?metadata:\s*{[\s\S]*?position:\s*")[^"]*(")/,
@@ -122,6 +145,9 @@ jQuery(document).ready(function($) {
122145
$('#frak_logo_file').on('change', handleLogoFileSelect);
123146
$('#frak_logo_url').on('input', handleLogoUrlChange);
124147

148+
// Bind i18n input events
149+
$('.frak-i18n-table input').on('input', updateConfig);
150+
125151
// Initialize toggles
126152
toggleFloatingButtonSettings();
127153

0 commit comments

Comments
 (0)