Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #11710 from brave/spellcheck-language-setting
Browse files Browse the repository at this point in the history
Spellcheck language settings (enable/disable & dictionary languages)
  • Loading branch information
bbondy committed Nov 1, 2017
2 parents 770c5f8 + 5884450 commit fc757e3
Show file tree
Hide file tree
Showing 16 changed files with 728 additions and 40 deletions.
23 changes: 23 additions & 0 deletions app/browser/reducers/spellCheckerReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const appConstants = require('../../../js/constants/appConstants')
const {makeImmutable} = require('../../common/state/immutableUtil')
const {getWebContents} = require('../webContentsCache')
const spellChecker = require('../../spellChecker')
const settings = require('../../../js/constants/settings')
const {setUserPref} = require('../../../js/state/userPrefs')
const getSetting = require('../../../js/settings').getSetting

const migrate = (state) => {
if (state.get('dictionary')) {
Expand All @@ -28,12 +31,32 @@ const migrate = (state) => {
return state
}

const setSpellCheckerSettings = () => {
const enabled = getSetting(settings.SPELLCHECK_ENABLED)
setUserPref('browser.enable_spellchecking', enabled)
if (enabled) {
setUserPref('spellcheck.dictionaries',
getSetting(settings.SPELLCHECK_LANGUAGES))
}
}

const spellCheckerReducer = (state, action, immutableAction) => {
action = immutableAction || makeImmutable(action)
switch (action.get('actionType')) {
case appConstants.APP_SET_STATE:
state = migrate(state)
break
// TODO(darkdh): APP_SET_STATE is too early for startup setting so we use
// APP_WINDOW_CREATED here
case appConstants.APP_WINDOW_CREATED:
setSpellCheckerSettings()
break
case appConstants.APP_CHANGE_SETTING:
if ([settings.SPELLCHECK_ENABLED, settings.SPELLCHECK_LANGUAGES]
.includes(action.get('key'))) {
setSpellCheckerSettings()
}
break
case appConstants.APP_SPELLING_SUGGESTED:
if (typeof action.get('suggestion') === 'string') {
const webContents = getWebContents(action.get('tabId'))
Expand Down
1 change: 1 addition & 0 deletions app/extensions/brave/about-preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<link rel="localization" href="locales/{locale}/error.properties">
<link rel="localization" href="locales/{locale}/errorMessages.properties">
<link rel="localization" href="locales/{locale}/extensions.properties">
<link rel="localization" href="locales/{locale}/locales.properties">
</head>
<body>
<div id="appContainer"/>
Expand Down
2 changes: 2 additions & 0 deletions app/extensions/brave/index-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<link rel="localization" href="locales/{locale}/menu.properties">
<link rel="localization" href="locales/{locale}/downloads.properties">
<link rel="localization" href="locales/{locale}/countries.properties">
<link rel="localization" href="locales/{locale}/locales.properties">
<link rel="localization" href="locales/{locale}/preferences.properties">
</head>
<body>
<div id="appContainer">
Expand Down
2 changes: 2 additions & 0 deletions app/extensions/brave/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<link rel="localization" href="locales/{locale}/menu.properties"/>
<link rel="localization" href="locales/{locale}/downloads.properties"/>
<link rel="localization" href="locales/{locale}/countries.properties"/>
<link rel="localization" href="locales/{locale}/locales.properties"/>
<link rel="localization" href="locales/{locale}/preferences.properties"/>
</head>
<body>
<div id="appContainer"/>
Expand Down
26 changes: 26 additions & 0 deletions app/extensions/brave/locales/en-US/locales.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
bn-BD=Bengali (Bangladesh)
bn-IN=Bengali (India)
cs=Czech
de-DE=German (Germany)
en-GB=English (U.K.)
en-US=English (U.S.)
es=Spanish
eu=Basque
fr-FR=French (France)
hi-IN=Hindi (India)
id-ID=Indonesian (Indonesia)
it-IT=Italian
ja-JP=Japanese (Japan)
ko-KR=Korean
ms-MY=Malay (Malaysia)
nl-NL=Dutch (Netherlands)
pl-PL=Polish
pt-BR=Portuguese (Brazil)
ru=Russian
sl=Slovenian
sv-SE=Swedish (Sweden)
ta=Tamil
te=Telugu
tr-TR=Turkish (Turkey)
uk=Ukrainian
zh-CN=Simplified Chinese (China)
29 changes: 2 additions & 27 deletions app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ bitcoinBalance=Please transfer:&nbsp;
bitwarden=bitwarden&reg;
blockAttackSites=Block reported attack sites (not available yet)
blockedCountBadge=Display block count badge on shields button
bn-BD=Bengali (Bangladesh)
bn-BD=Bengali (Bangladesh)
bn-IN=Bengali (India)
bookmarksBarFaviconOnly=Favicons only
bookmarksBarTextAndFavicon=Text and Favicons
bookmarksBarTextOnly=Text only
Expand Down Expand Up @@ -96,12 +93,10 @@ createWallet=create wallet
createWalletStatus=Click the Create Wallet button to get started.
creatingWallet=creating…
creatingWalletStatus=Creating wallet…
cs=Czech
dashboardSettingsTitle=Dashboard
dashboardShowImages=Show images
dashlane=Dashlane&reg; (requires application)
date=Date
de-DE=German (Germany)
default=Default
default=Default
defaultBrowser=Brave is your default browser.
Expand All @@ -121,8 +116,7 @@ downloadsAskAlwaysSwitch=Always ask me where to save files
downloadsInput=~/downloads/
downloadsLabel=Save my downloads here:
emailAddress=Email address
en-GB=English (U.K.)
en-US=English (U.S.)
enableSpellCheck=Enable Spell Check *
enableAutofill=Enable Autofill
enableFlash=Enable Adobe Flash support
enableFlashSubtext=Brave uses a special version of Pepper Flash which must be installed from
Expand All @@ -134,36 +128,28 @@ enableWidevine=Enable Google Widevine support
engineGoKey=Engine Go Key (Type First)
engineGoKey=Engine Go Key (type first)
enpass=Enpass&reg; (requires application)
es=Spanish
eu=Basque
extensions=Extensions
firstKey=Key 1
firstRecoveryKey=Recovery Key 1
flash=Run Adobe Flash Player
flashAllowAlways=Allow until {{time}}
flashTroubleshooting=Flash not working? Try the troubleshooting tips on our
fr-FR=French (France)
fullscreenContent=Full Screen Content
fullscreenPermission=Fullscreen access
general=General
generalSettings=General Settings
geolocationPermission=Location access
hi-IN=Hindi (India)
hideExcluded=Show only included sites
hint0=The site shields panel allows you to turn HTTPS Everywhere on or off. HTTPS Everywhere automatically changes your HTTP traffic to HTTPS for supported sites to keep you more secure.
hint1=Brave will always auto-update for you, but you can check for an update on demand in the menu.
hint2=The File menu allows you to create a New Session Tab. Session tabs are like any other tab but they run in a different user profile. This allows you to login to the same sites multiple times with the same browser.
hintsTitle=Helpful hints
id-ID=Indonesian (Indonesia)
importBrowserData=Import Browser Data
importButton=Import now…
importLabel=Browser data import:
importNow=Import now…
include=Include
insufficientFundsStatus=Your account balance is under your budget for this month. Please add funds.
it-IT=Italian
ja-JP=Japanese (Japan)
ko-KR=Korean
lastContribution=Last contribution:
lastPass=LastPass&reg;
ledgerBackupText1=Below, you will find the anonymized recovery key that is required if you ever lose access to this computer.
Expand Down Expand Up @@ -199,7 +185,6 @@ minimumVisitsLow=1 visit
minimumVisitsMedium=5 visits
minimumVisitsSetting=Minimum visits for publisher relevancy
monthlyBudget=monthly budget
ms-MY=Malay (Malaysia)
multipleHomePages.title=Multiple home pages
myHomepage=My home page is
newTabBlank=blank
Expand All @@ -209,7 +194,6 @@ newTabHomePage=Home page
newTabMode=A new tab shows
newTabNewTabPage=Dashboard
nextContribution=Next contribution:
nl-NL=Dutch (Netherlands)
nonVerifiedPublishers=Allow contributions to non-verified sites
noPaymentHistory=No previous contributions
normal=Normal
Expand Down Expand Up @@ -252,7 +236,6 @@ paymentsWelcomeTitle=Welcome to Brave Payments!
pendingFundsStatus=Pending funds: {{funds}}. Newly-added funds may take 30+ minutes to appear.
percentage=%
percentPaid=Percentage
pl-PL=Polish
plugins=Plugins
pluginSettings=Plugin Settings
pointerLockPermission=Disable your mouse cursor
Expand All @@ -262,7 +245,6 @@ privacy=Privacy
privateData=Private Data
privateDataMessage=Clear the following data types when I close Brave
protocolRegistrationPermission=Protocol registration
pt-BR=Portuguese (Brazil)
publisher=Site
publishers=Publishers
rank=Rank
Expand All @@ -273,7 +255,6 @@ recoveryKey=Recovery Key
recoverLedger=Recover your wallet
remove=Remove
requiresRestart=* Requires browser restart
ru=Russian
savedSiteSettings=Saved site settings and permissions
saveRecoveryFile=Save recovery file…
scaleSizeLarger=Larger
Expand Down Expand Up @@ -309,7 +290,7 @@ showTopsiteSuggestions=Show top site suggestions
site=Site
sitePermissions=Saved Site Permissions
sitePermissionsExceptions=Saved Site Exceptions
sl=Slovenian
spellCheckLanguages=Spell Check Languages *
startsWith=Brave starts with
startsWithOptionHomePage=Home page
startsWithOptionLastTime=My windows / tabs from last time
Expand All @@ -320,7 +301,6 @@ statusNextReconcileOverdue=Overdue
statusNextReconcileToday=Today
statusOnError=Brave Wallet can't be reached.
submitFeedback=Submit Feedback…
sv-SE=Swedish (Sweden)
swipeNavigationDistance=Swipe Navigation Distance
switchToNewTabs=Switch to new tabs immediately
sync=Sync
Expand Down Expand Up @@ -359,7 +339,6 @@ syncSiteSettings=Saved site settings
syncStart=I am new to Sync
syncTitle=Brave Sync
syncTitleMessage=Sync encrypted browser data between your devices securely and privately using Brave Sync.
ta=Tamil
tabCloseAction=When closing an active tab:
tabCloseActionLastActive=Select the last viewed tab
tabCloseActionNext=Select the next tab
Expand All @@ -370,12 +349,9 @@ tabs=Tabs
tabSettings=Tab Settings
tabsPerTabPage=Number of tabs per tab set:
tabsSettings=Tabs Settings
te=Telugu
timeSpent=Time Spent
toolbarUserInterfaceScale=Toolbar and UI elements scale
totalAmount=Total Amount
tr-TR=Turkish (Turkey)
uk=Ukrainian
update=Update
updateToPreviewReleases=Update to preview releases *
urlBarOptions=URL Bar Options
Expand All @@ -391,4 +367,3 @@ visits=Visits
wideURLbar=Use wide URL bar
widevine=Run Google Widevine
widevineSection=Google Widevine Support
zh-CN=Chinese
23 changes: 13 additions & 10 deletions app/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,9 @@ var rendererIdentifiers = function () {
'autoplayMedia',
// Release channels
'channelDev',
'channelBeta'
].concat(countryCodes)
'channelBeta',
'spellCheckLanguages'
].concat(countryCodes).concat(availableLanguages)
}

var ctx = null
Expand Down Expand Up @@ -302,32 +303,32 @@ exports.translation = function (token, replacements = {}) {
const DEFAULT_LANGUAGE = 'en-US'

const availableLanguages = [
'eu',
'bn-BD',
'bn-IN',
'zh-CN',
'cs',
'nl-NL',
'en-US',
'de-DE',
'en-GB',
'en-US',
'es',
'eu',
'fr-FR',
'de-DE',
'hi-IN',
'id-ID',
'it-IT',
'ja-JP',
'ko-KR',
'ms-MY',
'nl-NL',
'pl-PL',
'pt-BR',
'ru',
'sl',
'sv-SE',
'es',
'ta',
'te',
'tr-TR',
'uk'
'uk',
'zh-CN'
]

// Currently configured languages
Expand Down Expand Up @@ -394,7 +395,9 @@ exports.init = function (language) {
path.join(__dirname, 'extensions', 'brave', 'locales', lang, 'error.properties'),
path.join(__dirname, 'extensions', 'brave', 'locales', lang, 'passwords.properties'),
path.join(__dirname, 'extensions', 'brave', 'locales', lang, 'common.properties'),
path.join(__dirname, 'extensions', 'brave', 'locales', lang, 'countries.properties')
path.join(__dirname, 'extensions', 'brave', 'locales', lang, 'countries.properties'),
path.join(__dirname, 'extensions', 'brave', 'locales', lang, 'locales.properties'),
path.join(__dirname, 'extensions', 'brave', 'locales', lang, 'preferences.properties')
)
}

Expand Down
Loading

0 comments on commit fc757e3

Please sign in to comment.