Skip to content

Conversation

Copy link

Copilot AI commented Nov 18, 2025

Implements Chrome extension i18n infrastructure for Turkish (default) and English with 55 translation keys covering all UI text, error messages, and Jira issue descriptions.

Implementation

Locale files (_locales/{tr,en}/messages.json)

  • 55 translation keys for all static text
  • Covers UI labels, buttons, errors, status messages, and Jira ADF content
  • Uses Chrome's standard __MSG_keyName__ pattern in manifest

Helper module (i18n.js)

i18n.getMessage(key)           // Get translated message
i18n.getPreferredLanguage()    // Retrieve stored preference
i18n.setPreferredLanguage(lang) // Save to Chrome sync storage
i18n.translatePage()           // Auto-translate data-i18n elements

Language switching

  • Dropdown in popup and settings pages
  • Auto-detects browser language on first use
  • Preference persists via Chrome sync storage

HTML integration

<div data-i18n="popupTitle">Jira Bug Reporter</div>
<input data-i18n-placeholder="placeholderJiraBaseUrl" placeholder="https://...">
<button data-i18n-title="btnCreateIssueTitle">
  <span data-i18n="btnCreateIssue">Create Issue</span>
</button>

Background service

// In background.js - translates even Jira issue descriptions
const msg = (key) => chrome.i18n.getMessage(key);
summary: `${msg("issueSummaryPrefix")} ${title} @ ${host}`

Screenshot

i18n Demo

Side-by-side view shows Turkish (left) and English (right) translations across all UI elements.

Files Modified

  • manifest.json - i18n refs (__MSG_extName__), default_locale: "tr"
  • popup.html/js, options.html/js - data-i18n attributes, language selector
  • background.js - i18n for errors and Jira content (ADF format)

Translation coverage includes extension metadata, all UI elements, error messages, and dynamically generated Jira issue descriptions.

Original prompt

Projede Türkçe ve İngilizce çoklu dil (i18n) desteği eklenmeli.

  • Uygulama, arayüz metinlerini kullanıcının seçimine veya tarayıcı/dil ayarına göre Türkçe ve İngilizce gösterebilmeli.
  • i18n altyapısı kurularak en az iki dil dosyası (tr.json ve en.json gibi) hazırlanmalı.
  • Tüm sabit metinler ilgili çeviri anahtarlarına taşınmalı.
  • Kullanıcı dil değiştirme işlemi yapabiliyorsa arayüz sağlanmalı, yoksa otomatik olarak sistem/brauzer diline göre belirlenmeli.

This pull request was created as a result of the following prompt from Copilot chat.

Projede Türkçe ve İngilizce çoklu dil (i18n) desteği eklenmeli.

  • Uygulama, arayüz metinlerini kullanıcının seçimine veya tarayıcı/dil ayarına göre Türkçe ve İngilizce gösterebilmeli.
  • i18n altyapısı kurularak en az iki dil dosyası (tr.json ve en.json gibi) hazırlanmalı.
  • Tüm sabit metinler ilgili çeviri anahtarlarına taşınmalı.
  • Kullanıcı dil değiştirme işlemi yapabiliyorsa arayüz sağlanmalı, yoksa otomatik olarak sistem/brauzer diline göre belirlenmeli.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Nov 18, 2025
Co-authored-by: saracmert <5950989+saracmert@users.noreply.github.com>
const key = el.getAttribute('data-i18n-html');
const url = el.getAttribute('data-i18n-url');
if (url) {
el.innerHTML = i18n.getMessage(key, url);

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.

Copilot Autofix

AI 2 months ago

To fix the problem, we should prevent untrusted data from being injected directly into the DOM as HTML. When setting innerHTML, any content should be properly sanitized or encoded. Since the current codebase leverages Chrome extension APIs and maintains a simple translation layer, the single best fix is to ensure that any data going to el.innerHTML is properly escaped. This can be done by replacing assignment to el.innerHTML with assignment to el.textContent, blocking all HTML interpretation, unless the intent is to inject trusted HTML (which, for translations, is rare and discouraged).

If rich HTML content must be supported, a robust sanitizer such as DOMPurify should be used. However, since CodeQL flagged unescaped meta-characters, the simple fix is to use el.textContent wherever possible.

Specifically, in src/i18n.js, lines 55 and 57 should be changed from assigning to el.innerHTML to assigning to el.textContent.

If the feature relies on translation strings containing actual HTML (e.g., for formatting), a sanitizer needs to be applied to the translation result before using innerHTML. If not, use textContent.

No new imports are needed unless we decide to use a sanitizer. For a plain security fix, use textContent in place of innerHTML.


Suggested changeset 1
src/i18n.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/i18n.js b/src/i18n.js
--- a/src/i18n.js
+++ b/src/i18n.js
@@ -52,9 +52,9 @@
       const key = el.getAttribute('data-i18n-html');
       const url = el.getAttribute('data-i18n-url');
       if (url) {
-        el.innerHTML = i18n.getMessage(key, url);
+        el.textContent = i18n.getMessage(key, url);
       } else {
-        el.innerHTML = i18n.getMessage(key);
+        el.textContent = i18n.getMessage(key);
       }
     });
   }
EOF
@@ -52,9 +52,9 @@
const key = el.getAttribute('data-i18n-html');
const url = el.getAttribute('data-i18n-url');
if (url) {
el.innerHTML = i18n.getMessage(key, url);
el.textContent = i18n.getMessage(key, url);
} else {
el.innerHTML = i18n.getMessage(key);
el.textContent = i18n.getMessage(key);
}
});
}
Copilot is powered by AI and may make mistakes. Always verify output.
if (url) {
el.innerHTML = i18n.getMessage(key, url);
} else {
el.innerHTML = i18n.getMessage(key);

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.
Co-authored-by: saracmert <5950989+saracmert@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Turkish and English i18n support Add i18n support for Turkish and English Nov 18, 2025
Copilot AI requested a review from saracmert November 18, 2025 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants