Index: compile_rules.py
==================================================================
--- compile_rules.py
+++ compile_rules.py
@@ -517,10 +517,11 @@
def prepareOptions (lOptionLines):
"returns a dictionary with data about options"
sLang = ""
+ sDefaultUILang = ""
lStructOpt = []
lOpt = []
dOptLabel = {}
dOptPriority = {}
for sLine in lOptionLines:
@@ -539,18 +540,21 @@
dOptPriority[m.group(1)] = int(m.group(2))
elif sLine.startswith("OPTLANG/"):
m = re.match("OPTLANG/([a-z][a-z](?:_[A-Z][A-Z]|)):(.+)$", sLine)
sLang = m.group(1)[:2]
dOptLabel[sLang] = { "__optiontitle__": m.group(2).strip() }
+ elif sLine.startswith("OPTDEFAULTUILANG:"):
+ m = re.match("OPTDEFAULTUILANG: *([a-z][a-z](?:_[A-Z][A-Z]|))$", sLine)
+ sDefaultUILang = m.group(1)[:2]
elif sLine.startswith("OPTLABEL/"):
m = re.match("OPTLABEL/([a-z0-9]+):(.+)$", sLine)
dOptLabel[sLang][m.group(1)] = list(map(str.strip, m.group(2).split("|"))) if "|" in m.group(2) else [m.group(2).strip(), ""]
else:
print("# Error. Wrong option line in:\n ")
print(sLine)
print(" options defined for: " + ", ".join([ t[0] for t in lOpt ]))
- dOptions = { "lStructOpt": lStructOpt, "dOptLabel": dOptLabel }
+ dOptions = { "lStructOpt": lStructOpt, "dOptLabel": dOptLabel, "sDefaultUILang": sDefaultUILang }
dOptions.update({ "dOpt"+k: v for k, v in lOpt })
return dOptions, dOptPriority
def printBookmark (nLevel, sComment, nLine):
@@ -585,11 +589,11 @@
print(sLine.strip())
elif sLine.startswith("TEST:"):
lTest.append("{:<8}".format(i) + " " + sLine[5:].strip())
elif sLine.startswith("TODO:"):
pass
- elif sLine.startswith(("OPTGROUP/", "OPTSOFTWARE:", "OPT/", "OPTLANG/", "OPTLABEL/", "OPTPRIORITY/")):
+ elif sLine.startswith(("OPTGROUP/", "OPTSOFTWARE:", "OPT/", "OPTLANG/", "OPTDEFAULTUILANG:", "OPTLABEL/", "OPTPRIORITY/")):
lOpt.append(sLine)
elif re.match("[ \t]*$", sLine):
pass
elif sLine.startswith("!!"):
m = zBookmark.search(sLine)
Index: gc_lang/fr/build.py
==================================================================
--- gc_lang/fr/build.py
+++ gc_lang/fr/build.py
@@ -18,13 +18,27 @@
"create Web-extension"
print("Building WebExtension")
helpers.createCleanFolder("_build/webext/"+sLang)
dir_util.copy_tree("gc_lang/"+sLang+"/webext/", "_build/webext/"+sLang)
dir_util.copy_tree("grammalecte-js", "_build/webext/"+sLang+"/grammalecte")
+ dVars['webextOptionsHTML'] = _createOptionsForWebExtension(dVars)
+ helpers.copyAndFileTemplate("_build/webext/"+sLang+"/panel/main.html", "_build/webext/"+sLang+"/panel/main.html", dVars)
with helpers.cd("_build/webext/"+sLang):
os.system("web-ext build")
+
+def _createOptionsForWebExtension (dVars):
+ sHTML = ""
+ sLang = dVars['sDefaultUILang']
+ for sSection, lOpt in dVars['lStructOpt']:
+ sHTML += f'\n
\n
{dVars["dOptLabel"][sLang][sSection][0]}
\n'
+ for lLineOpt in lOpt:
+ for sOpt in lLineOpt:
+ sHTML += f'
\n'
+ sHTML += '
\n'
+ return sHTML
+
def createFirefoxExtension (sLang, dVars):
"create extension for Firefox"
print("Building extension for Firefox")
helpers.createCleanFolder("_build/xpi/"+sLang)
@@ -52,11 +66,11 @@
sHTML += ' \n'
sHTML += '\n'
# Creating translation data
dProperties = {}
for sLang in dVars['dOptLabel'].keys():
- dProperties[sLang] = "\n".join( [ "option_" + sOpt + " = " + dVars['dOptLabel'][sLang][sOpt][0].replace(" [!]", " [!]") for sOpt in dVars['dOptLabel'][sLang] ] )
+ dProperties[sLang] = "\n".join( [ "option_" + sOpt + " = " + dVars['dOptLabel'][sLang][sOpt][0].replace(" [!]", " [!]") for sOpt in dVars['dOptLabel'][sLang] ] )
return sHTML, dProperties
def createThunderbirdExtension (sLang, dVars, spLangPack):
"create extension for Thunderbird"
Index: gc_lang/fr/rules.grx
==================================================================
--- gc_lang/fr/rules.grx
+++ gc_lang/fr/rules.grx
@@ -98,10 +98,11 @@
# Priority: from 0 to 9. Default priority is 4.
OPTPRIORITY/tu: 6
OPTPRIORITY/conf: 5
OPTPRIORITY/ocr: 3
+OPTDEFAULTUILANG: fr_FR
# Labels
OPTLANG/fr_FR: Grammalecte (Français)
OPTLABEL/basic: Typographie
OPTLABEL/typo: Signes typographiques
Index: gc_lang/fr/webext/panel/main.css
==================================================================
--- gc_lang/fr/webext/panel/main.css
+++ gc_lang/fr/webext/panel/main.css
@@ -120,13 +120,10 @@
#page h1 {
margin: 0 0 10px 0;
color: hsl(210, 70%, 70%);
font: bold 30px 'Yanone Kaffeesatz', "Liberation Sans Narrow", sans-serif;
}
-#page p {
- margin: 10px 0 5px 0;
-}
/*
Home
*/
@@ -133,13 +130,10 @@
#home_page {
display: block;
background-color: hsl(210, 20%, 92%);
min-height: 100%;
}
-#home_page p {
- margin: 0;
-}
#home_page #mainlogo {
padding: 5px 20px 20px 20px;
background-color: hsl(210, 20%, 96%);
}
#home_page .notice {
@@ -168,11 +162,38 @@
Grammar checking options
*/
#gc_options_page {
display: none;
padding: 20px;
- background-color: hsl(0, 50%, 90%);
+}
+.opt_subsection {
+ margin: 5px 0;
+ padding: 10px;
+ background-color: hsl(210, 20%, 92%);
+ border-radius: 3px;
+}
+.opt_subsection h2 {
+ color: hsl(210, 30%, 50%);
+ margin-bottom: 3px;
+ font-size: 16px;
+ font-family: "Trebuchet MS", sans-serif;
+}
+.opt_subsection p {
+ padding: 2px 3px;
+ display: flex;
+ align-items: center;
+}
+.opt_subsection p:hover {
+ background-color: hsl(210, 20%, 86%);
+ border-radius: 2px;
+}
+.opt_subsection label {
+ flex: 1;
+ font-size: 12px;
+}
+.opt_subsection input {
+ order: 1
}
/*
Spell checking options
@@ -179,13 +200,10 @@
*/
#sc_options_page {
display: none;
padding: 20px;
}
-#sc_options_page p {
- margin: 0;
-}
#dictionaries_info {
margin: 10px 0;
padding: 10px;
border-radius: 3px;
background-color: hsl(0, 50%, 40%);
Index: gc_lang/fr/webext/panel/main.html
==================================================================
--- gc_lang/fr/webext/panel/main.html
+++ gc_lang/fr/webext/panel/main.html
@@ -75,11 +75,11 @@
OPTIONS GRAMMATICALES
- ${optionsHTML}
+ ${webextOptionsHTML}
Options par défaut