Skip to content

Commit

Permalink
[DuckPlayer] 24. FrontEnd Translation (#3281)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/1204099484721401/1208149666429213/f

Description:

Translates Duckplayer FrontEnd and updates copy based on Ship Review
Removes copy from DP footer in settings
Updates Copy for DuckPlayer Prompt and Settings to be new, and the same
  • Loading branch information
afterxleep authored Aug 28, 2024
1 parent e3d73bb commit fc0ea9b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
37 changes: 25 additions & 12 deletions DuckDuckGo/DuckPlayer/DuckPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Foundation
import WebKit
import UserScript
import Core
import ContentScopeScripts

/// Values that the Frontend can use to determine the current state.
struct InitialPlayerSettings: Codable {
Expand All @@ -48,16 +49,13 @@ struct InitialPlayerSettings: Codable {
case development
case production
}

enum Locale: String, Codable {
case en
}

let userValues: UserValues
let ui: UIValues
let settings: PlayerSettings
let platform: Platform
let locale: Locale
let locale: String
let localeStrings: String?
}

/// Values that the Frontend can use to determine user settings
Expand Down Expand Up @@ -105,11 +103,25 @@ final class DuckPlayer: DuckPlayerProtocol {
struct Constants {
static let duckPlayerHost: String = "player"
static let commonName = "Duck Player"
static let translationFile = "duckplayer"
static let translationFileExtension = "json"
static let defaultLocale = "en"
static let translationPath = "pages/duckplayer/locales/"
}

private(set) var settings: DuckPlayerSettingsProtocol
private(set) weak var hostView: UIViewController?

private lazy var localeStrings: String? = {
let languageCode = Locale.current.languageCode ?? Constants.defaultLocale
if let localizedFile = ContentScopeScripts.Bundle.path(forResource: Constants.translationFile,
ofType: Constants.translationFileExtension,
inDirectory: "\(Constants.translationPath)\(languageCode)") {
return try? String(contentsOfFile: localizedFile)
}
return nil
}()

private struct WKMessageData: Codable {
var context: String?
var featureName: String?
Expand Down Expand Up @@ -213,16 +225,17 @@ final class DuckPlayer: DuckPlayerProtocol {
let isPiPEnabled = webView?.configuration.allowsPictureInPictureMediaPlayback == true
let pip = InitialPlayerSettings.PIP(status: isPiPEnabled ? .enabled : .disabled)
let platform = InitialPlayerSettings.Platform(name: "ios")
// let environment = InitialPlayerSettings.Environment.development
let locale = InitialPlayerSettings.Locale.en
let locale = Locale.current.languageCode ?? "en"
let playerSettings = InitialPlayerSettings.PlayerSettings(pip: pip)
let userValues = encodeUserValues()
let uiValues = encodeUIValues()
return InitialPlayerSettings(userValues: userValues,
ui: uiValues,
settings: playerSettings,
platform: platform,
locale: locale)
let settings = InitialPlayerSettings(userValues: userValues,
ui: uiValues,
settings: playerSettings,
platform: platform,
locale: locale,
localeStrings: localeStrings)
return settings
}

// Accessing WKMessage needs main thread
Expand Down
4 changes: 0 additions & 4 deletions DuckDuckGo/SettingsDuckPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ struct SettingsDuckPlayerView: View {
options: DuckPlayerMode.allCases,
selectedOption: viewModel.duckPlayerModeBinding)
.disabled(viewModel.shouldDisplayDuckPlayerContingencyMessage)
} footer: {
Text(UserText.settingsDuckPlayerFooter)
.daxFootnoteRegular()
.multilineTextAlignment(.center)
}
}
.applySettingsListModifiers(title: UserText.duckPlayerFeatureName,
Expand Down
6 changes: 3 additions & 3 deletions DuckDuckGo/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1267,10 +1267,10 @@ But if you *do* want a peek under the hood, you can find more information about
public static let settingsOpenVideosInDuckPlayerTitle = NSLocalizedString("duckplayer.settings.title", value: "Duck Player", comment: "Settings screen cell text for DuckPlayer settings")
public static let settingsDuckPlayerFooter = NSLocalizedString("duckplayer.settings.footer", value: "DuckDuckGo provides all the privacy essentials you need to protect yourself as you browse the web.", comment: "Footer label in the settings screen for Duck Player")
public static let settingsDuckPlayerLearnMore = NSLocalizedString("duckplayer.settings.learn-more", value: "Learn More", comment: "Button that takes the user to learn more about Duck Player.")
public static let settingsDuckPlayerInfoText = NSLocalizedString("duckplayer.settings.info-text", value: "Duck Player provides a clean viewing experience without personalized ads and prevents viewing activity from influencing your YouTube recommendations.", comment: "Text explaining what Duck Player is in the settings screen.")
public static let settingsDuckPlayerInfoText = NSLocalizedString("duckplayer.settings.info-text", value: "Duck Player lets you watch YouTube without targeted ads in DuckDuckGo and what you watch won’t influence your recommendations.", comment: "Text explaining what Duck Player is in the settings screen.")

public static let duckPlayerPresentationModalTitle = NSLocalizedString("duckplayer.presentation.modal.title", value: "Drowning in ads on YouTube? Try Duck Player!", comment: "Two line title (separated by \n) for the feature explanation")
public static let duckPlayerPresentationModalBody = NSLocalizedString("duckplayer.presentation.modal.body", value: "Duck Player lets you watch YouTube without targeted ads in a theater-like experience in DuckDuckGo and what you watch won’t influence your recommendations.", comment: "Body text for the modal feature explanation")
public static let duckPlayerPresentationModalTitle = NSLocalizedString("duckplayer.presentation.modal.title", value: "Drowning in ads on YouTube? Not with Duck Player!", comment: "Two line title (separated by \n) for the feature explanation")
public static let duckPlayerPresentationModalBody = NSLocalizedString("duckplayer.presentation.modal.body", value: "Duck Player lets you watch YouTube without targeted ads in DuckDuckGo and what you watch won’t influence your recommendations.", comment: "Body text for the modal feature explanation")
public static let duckPlayerPresentationModalDismissButton = NSLocalizedString("duckplayer.presentation.modal.dismiss-button", value: "Got it!", comment: "Button that will dismiss the modal")

static let duckPlayerContingencyMessageTitle = NSLocalizedString("duck-player.contingency-title", value: "Duck Player Unavailable", comment: "Title for message explaining to the user that Duck Player is not available")
Expand Down
6 changes: 3 additions & 3 deletions DuckDuckGo/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1002,19 +1002,19 @@
"duckPlayer.never.label" = "Never";

/* Body text for the modal feature explanation */
"duckplayer.presentation.modal.body" = "Duck Player lets you watch YouTube without targeted ads in a theater-like experience in DuckDuckGo and what you watch won’t influence your recommendations.";
"duckplayer.presentation.modal.body" = "Duck Player lets you watch YouTube without targeted ads in DuckDuckGo and what you watch won’t influence your recommendations.";

/* Button that will dismiss the modal */
"duckplayer.presentation.modal.dismiss-button" = "Got it!";

/* Two line title (separated by \n) for the feature explanation */
"duckplayer.presentation.modal.title" = "Drowning in ads on YouTube? Try Duck Player!";
"duckplayer.presentation.modal.title" = "Drowning in ads on YouTube? Not with Duck Player!";

/* Footer label in the settings screen for Duck Player */
"duckplayer.settings.footer" = "DuckDuckGo provides all the privacy essentials you need to protect yourself as you browse the web.";

/* Text explaining what Duck Player is in the settings screen. */
"duckplayer.settings.info-text" = "Duck Player provides a clean viewing experience without personalized ads and prevents viewing activity from influencing your YouTube recommendations.";
"duckplayer.settings.info-text" = "Duck Player lets you watch YouTube without targeted ads in DuckDuckGo and what you watch won’t influence your recommendations.";

/* Button that takes the user to learn more about Duck Player. */
"duckplayer.settings.learn-more" = "Learn More";
Expand Down

0 comments on commit fc0ea9b

Please sign in to comment.