Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autofill: send current language in runtime config #808

Merged
merged 1 commit into from
May 10, 2024

Conversation

sjbarag
Copy link
Contributor

@sjbarag sjbarag commented May 3, 2024

ℹ️ This PR replaces #752. There's a small amount of extra context in that PR, based on my original diff ℹ️

Required:

Task/Issue URL: https://app.asana.com/0/11984721910118/1206933877192910/f
iOS PR: N/A
macOS PR: N/A
What kind of version bump will this require?: Patch. This is backwards-compatible, and the autofill codebase falls back to 'en' when it doesn't receive a language.

Optional:

Tech Design URL: N/A
CC: @amddg44 @shakyShane

Description:
The HTML autofill UI will be translated shortly, but doing so is only possible once that UI knows which language to use. Send the current locale's two-character language code as part of the privacy config (aka 'runtime config' in the autofill codebase).

This is a backwards-compatible change, since 'language' is currently an optional input to the autofill HTML pages.

Steps to test this PR:

  1. Use autofill from l10n: add basic localization support to device abstraction duckduckgo-autofill#541 + l10n: extract remaining strings to prepare for localization duckduckgo-autofill#558
  2. Use BSK from this PR
  3. (Optional) Apply this patch to force a pseudolocale:
diff --git a/Sources/BrowserServicesKit/ContentScopeScript/ContentScopeUserScript.swift b/Sources/BrowserServicesKit/ContentScopeScript/ContentScopeUserScript.swift
index 87beab7e..7e1530ec 100644
--- a/Sources/BrowserServicesKit/ContentScopeScript/ContentScopeUserScript.swift
+++ b/Sources/BrowserServicesKit/ContentScopeScript/ContentScopeUserScript.swift
@@ -34,7 +34,7 @@ public final class ContentScopeProperties: Encodable {
     public init(gpcEnabled: Bool, sessionKey: String, featureToggles: ContentScopeFeatureToggles) {
         self.globalPrivacyControlValue = gpcEnabled
         self.sessionKey = sessionKey
-        languageCode = Locale.current.languageCode ?? "en"
+        languageCode = "xa"
         features = [
             "autofill": ContentScopeFeature(featureToggles: featureToggles)
         ]
  1. Build and launch the macOS app
  2. Load any webpage with a signup form (I typically use IMDB)
  3. Click on Dax
  4. Confirm translation of the "Block email trackers" text under your personal Duck address:
    1. If you didn't apply the pseudolocale patch, you should still see English (the default in Autofill):
      image
    2. If you did apply the pseudolocale patch, you should see text that almost looks like English if you squint, but also has some repeated l33tspeak-style symbols:
      image

OS Testing:

  • iOS 14 — No changes, if I understand correctly.
  • iOS 15 — No changes, if I understand correctly.
  • iOS 16 — No changes, if I understand correctly.
  • macOS 10.15 — I don't have 10.15 available
  • macOS 11 — I don't have 11 available
  • macOS 12 — Looking into it
  • macOS 14

Internal references:

Software Engineering Expectations
Technical Design Template


The HTML autofill UI will be translated shortly, but doing so is only
possible once that UI knows which language to use. Send the current
locale's two-character language code as part of the privacy config (aka
'runtime config' in the autofill codebase).

This is a backwards-compatible change, since 'language' is currently an
optional input to the autofill HTML pages.
Copy link
Contributor

@amddg44 amddg44 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👏

@amddg44 amddg44 merged commit 49d6842 into duckduckgo:main May 10, 2024
5 checks passed
samsymons added a commit that referenced this pull request May 10, 2024
* main:
  Enable gzip compression for Sync PATCH payloads (#803)
  autofill: send current language in runtime config (#808)
  Password manager survey update (#811)
  on iOS allow bookmarks in top hits (#812)
  Rename tests to avoid conflicts (#813)
  Bat.js fix (fix for installing content blocking rules multiple times) (#779)
  Pixels automatic naming prefixing fixed (#810)
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.

None yet

2 participants