Skip to content

Commit

Permalink
Merge pull request #560 from thunderbird/v14.0.2
Browse files Browse the repository at this point in the history
V14.0.2
  • Loading branch information
cleidigh authored Apr 19, 2024
2 parents efd8344 + 0c48c41 commit c9d0470
Show file tree
Hide file tree
Showing 180 changed files with 16,903 additions and 13,138 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
"gFolderDisplay": "readonly",
"IOUtils": "readonly",
"PathUtils": "readonly",
"globalThis": "readonly",

"BatchMessageMover": "readonly"

},
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

## Versions

Version 14.0.2 : Subfolders Release - April 10, 2024

- New: Recursive Subfolder Export for EML, HTML, PDF and Plaintext #538
- New: Size column in index #508
- New: Import OSX 9- CR terminations mbox files #540
- New: Support shortcuts for ExportSelectedMessages #519
- New: Czech (cs) locale - @cewbdex
- Fix mbox From_ separator to use asctime() date format #537
- Fix PDF exports do not use Mozilla Save toPDF settings #528
- Fix Right-clicking folder doesn't show export mbox option for Maildir #525
- Fix Cannot import emails with linebreaks in Return-Path header #516
- Fix Export all messages of a virtual folder to html with attachments and index - missing messages folder #509
- Fix context menu for message window #505
- Convert dtd files to messages.json



Version 14.0.1 : Maintenance Release - November 10, 2023

- New: Add Account level mbox import
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "ImportExportTools NG",
"name": "import-export-tools-ng",
"version": "14.0.1",
"version": "14.0.2",
"description": "Import and export next-gen tools for messages and folders",
"author": "Christopher Leidigh",
"engines": {
Expand Down
24 changes: 24 additions & 0 deletions scripts/convert.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
python locale-converter.py ..\src\chrome\locale\cs\mboximport ..\src\_locales\cs



python locale-converter.py ..\src\chrome\locale\de\mboximport ..\src\_locales\de
python locale-converter.py ..\src\chrome\locale\ca\mboximport ..\src\_locales\ca
python locale-converter.py ..\src\chrome\locale\da\mboximport ..\src\_locales\da
python locale-converter.py ..\src\chrome\locale\el\mboximport ..\src\_locales\el
python locale-converter.py ..\src\chrome\locale\es-ES\mboximport ..\src\_locales\es-ES
python locale-converter.py ..\src\chrome\locale\fr\mboximport ..\src\_locales\fr
python locale-converter.py ..\src\chrome\locale\gl-ES\mboximport ..\src\_locales\gl-ES
python locale-converter.py ..\src\chrome\locale\hu-HU\mboximport ..\src\_locales\hu-HU
python locale-converter.py ..\src\chrome\locale\hy-AM\mboximport ..\src\_locales\hy-AM
python locale-converter.py ..\src\chrome\locale\it\mboximport ..\src\_locales\it
python locale-converter.py ..\src\chrome\locale\ja\mboximport ..\src\_locales\ja
python locale-converter.py ..\src\chrome\locale\ko-KR\mboximport ..\src\_locales\ko-KR
python locale-converter.py ..\src\chrome\locale\nl\mboximport ..\src\_locales\nl
python locale-converter.py ..\src\chrome\locale\pl\mboximport ..\src\_locales\pl
python locale-converter.py ..\src\chrome\locale\pt-PT\mboximport ..\src\_locales\pt-PT
python locale-converter.py ..\src\chrome\locale\ru\mboximport ..\src\_locales\ru
python locale-converter.py ..\src\chrome\locale\sk-SK\mboximport ..\src\_locales\sk-SK
python locale-converter.py ..\src\chrome\locale\sl-SI\mboximport ..\src\_locales\sl-SI
python locale-converter.py ..\src\chrome\locale\sv-SE\mboximport ..\src\_locales\sv-SE
python locale-converter.py ..\src\chrome\locale\zh-CN\mboximport ..\src\_locales\zh-CN
174 changes: 174 additions & 0 deletions scripts/locale-converter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
#!/usr/bin/env python3

# This file is provided by the addon-developer-support repository at
# https://github.com/thundernest/addon-developer-support
#
# Version: 1.1
#
# Author: John Bieling ([email protected]), gNeander
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import os, sys, json, re, io, shlex

#------------------------------------------------

def newDir(dir):
if not os.path.exists(dir):
print("Directory doesn't exist. Creating. <" + dir + ">")
os.makedirs(dir)

def convert(source, destination, current = None, level = 1):
dir = source if current == None else current
messages = []

for name in os.listdir(dir):
path = os.path.join(dir, name)

if os.path.isfile(path):
if path.endswith('profilewizard.dtd'):
messages.extend(convert_dtd(path, dir))
#if path.endswith('.properties'):
# messages.extend(convert_prop(path, dir))

else:
messages.extend(convert(source, destination, path, level+1))

if level > 1:
return messages
elif level == 1 and messages:
# map the path from the source into the destination folder
dest = dir.replace(source, destination);
messagesjson = os.path.join(dest, "messages.json")
newDir(dest)

# check if the messagesjson already exists
oldData = None
if os.path.exists(messagesjson):
with open(messagesjson, "r", encoding='utf-8') as f:
oldData = json.load(f)

# merge data
newData = json.loads("{" + ", ".join(messages) + "}")
if oldData:
mergedData = oldData
mergedData.update(newData)
else:
mergedData = newData

# write pretty printed json file
final = json.dumps(mergedData, indent=4, sort_keys=True, ensure_ascii=False)
with io.open(messagesjson, "w", encoding='utf-8') as f:
f.write(final)
print(final)

# check the file for correctness
print(" -> TESTING " + messagesjson)
with open(messagesjson, "r", encoding='utf-8') as f:
d = json.load(f)
#print(d)

return []



def convert_dtd(path, dir):
print(" CONVERTING <" + path + "> to JSON")

sdtd = []

dtd = io.open(path, 'r', encoding='utf-8')
dtdTokens = shlex.split(dtd.read(), posix=False)

for i, j in enumerate(dtdTokens):
if j == "<!ENTITY":
sdtd.append(' "' + dtdTokens[i+1].strip() +'" : ' + json.dumps({ "message" : dtdTokens[i+2].strip()[1:-1] }))

return sdtd


def convert_prop(path, dir):
print(" CONVERTING <" + path + "> to JSON")

sprop = []
prop = io.open(path, 'r', encoding='utf-8')
propLines = prop.readlines()

for line in propLines:
sline = line.strip().replace('\r','').replace('\n','')
#print("next line >>" + line + "<<")

if sline != '' and sline[0] != '#':
a = sline.split('=')

# search for %S and replace them by $P1$, $P2" and so on
count = 0;
placeholders = {};
while True:
idx = a[1].find("%S")
if (idx == -1):
break
count += 1
a[1] = a[1].replace("%S", "$P" + str(count) + "$", 1)
placeholders["P" + str(count)] = { "content" : "$" + str(count) }

data = {}
data["message"] = a[1].strip();
if len(placeholders) > 0:
data["placeholders"] = placeholders

sprop.append(' "' + a[0].strip() +'" : ' + json.dumps(data));

return sprop


if __name__ == "__main__":

print ("""
This python3 script converts legacy locale files (*.properties and *.dtd)
to the new WebExt JSON format.""")

if (len(sys.argv) < 2 or len(sys.argv) > 3):
print ("""
Legacy WebExt
------ ------
locale _locales
|__ <languageX> |__ <languageX>
|__ <myaddon.dtd> |__ <messages.json>
|__ <myaddon.properties>
Usage:
py locale-converter.py <source> [<destination>]
If the destination folder (WebExt _locales folder) is not specified,
the specified source folder (legacy locale folder) will be used as
the destination folder.
If there is an existing messages.json at the final destination, the
script will attempt to merge the new strings into it.
Testing:
Each created JSON file is tested with the python function json.load(f),
which will throw an error in case something went wrong. Run a JSON
validator on the created json files to learn more about the error.
JSON Validators:
https://jsonlint.com/
http://jsoneditoronline.org/
https://jsonformatter.curiousconcept.com/
""")

exit()

# use source as destination, if not specified
source = sys.argv[1];
destination = sys.argv[1];
if (len(sys.argv) == 3):
destination = sys.argv[2];

convert(source, destination)

print( """Done""")
59 changes: 39 additions & 20 deletions scripts/translate-gc.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ var translationArray5 = [

var translationArray = [

{ key: "openHelpInWindow.label", text: "Open help in a window instead of a tab"},
{ key: "CRconversion.statusMsg", text: "Converting CR => CRLF line terminations"},




Expand Down Expand Up @@ -514,9 +515,10 @@ function loadTranslationArray(inputFiles, options) {
translateAll(iFile, strings, options);
break;
case '.json':
strings = loadMessageStrings(iFile, options);
translationArray = loadMessageStrings(iFile, options);
options.propertiesType = false;
translateAll(iFile, strings, options);
//translateAll(iFile, strings, options);
console.log(translationArray)
break;

default:
Expand Down Expand Up @@ -564,6 +566,18 @@ function convert(iFile, options) {
});
}

var cs = "python locale-converter.py ..\\src\\chrome\\locale\\${l1}\\mboximport ..\\src\\_locales\\${l2}"

function locs() {
localeFolders.forEach(loc => {
let s = cs
s = s.replace("${l1}",loc)
s = s.replace("${l2}",loc)

console.log(s)
});

}

var options3 = {
inputLocaleDir: `./src/_locales/en-US`,
Expand All @@ -575,7 +589,7 @@ var options3 = {
};

// dtd=2
var options = {
var options0 = {
inputLocaleDir: `./src/chrome/locale/en-US/mboximport`,
outputLocaleDir: "./src/chrome/locale",
outputLocaleDirSuffix: "mboximport/",
Expand All @@ -585,20 +599,24 @@ var options = {
};

// properties=1
var options1 = {
var options2 = {
inputLocaleDir: `./src/chrome/locale/en-US/mboximport`,
outputLocaleDir: "./src/chrome/locale",
outputLocaleDirSuffix: "mboximport/",
append: true,
append: false,
skipEN: true,
outputFormat: 1,
};

var options4 = {
inputLocaleDir: `./src/chrome/locale/en-US/mboximport`,
//inputLocaleDir: `./src/chrome/locale/en-US/mboximport`,

var options = {
inputLocaleDir: `./src/_locales/en-US`,

outputLocaleDir: "./src/_locales",
outputLocaleDirSuffix: "",
append: false,
skipEN: false,
append: true,
outputFormat: 3,
};

Expand All @@ -610,8 +628,8 @@ let inputFiles;
// let inputFiles = ["settings.dtd", "overlay.dtd", "overlay.properties"];


//let inputFiles = ["messages.json"];
inputFiles = ["mboximport.dtd"];
inputFiles = ["messages.json"];
//inputFiles = ["mboximport.dtd"];
// let inputFiles = ["autobackup.dtd", "autobackup.properties", "mboximport.dtd", "mboximport.properties", "profilewizard.dtd", "profilewizard.properties"];
//inputFiles = ["mboximport.properties"];
// var supportedLocales = ['de', 'en-US', 'nl', 'fr', 'it', 'zh-CN', 'ja', 'es-ES', 'ru', 'hu-HU', 'hy-AM', 'ko-KR',
Expand All @@ -621,30 +639,31 @@ localeFolders = ['de', 'en-US', 'nl', 'fr', 'it', 'zh-CN', 'ja', 'es-ES', 'ru',
'el', 'pl', 'da', 'pt-PT', 'ca', 'gl-ES', 'sk-SK', 'sl-SI', 'sv-SE'];

// full locale set
localeFolders = ['en-US', 'de', 'ca', 'da', 'el', 'es-ES', 'fr', 'gl-ES', 'hu-HU', 'hy-AM', 'it', 'ja', 'ko-KR',
localeFolders = ['en-US', 'de', 'ca', 'cs', 'da', 'el', 'es-ES', 'fr', 'gl-ES', 'hu-HU', 'hy-AM', 'it', 'ja', 'ko-KR',
'nl', 'pl', 'pt-PT', 'ru', 'sk-SK', 'sl-SI', 'sv-SE', 'zh-CN'];

// unmanaged help locales
//localeFolders = ['en-US', 'ca', 'el', 'es-ES', 'gl-ES', 'hu-HU', 'hy-AM', 'it', 'ko-KR',
// 'nl', 'pl', 'pt-PT', 'ru', 'sk-SK', 'sl-SI', 'sv-SE', 'zh-CN'];
localeFolders = ['en-US', 'ca', 'cs', 'el', 'es-ES', 'gl-ES', 'hu-HU', 'hy-AM', 'it', 'ko-KR',
'nl', 'pl', 'pt-PT', 'ru', 'sk-SK', 'sl-SI', 'sv-SE', 'zh-CN'];


// managed help locales
//localeFolders = ['de', 'ja', 'fr', 'da'];


//localeFolders = ['en-US', 'de'];

// localeFolders = ['ru', 'hu-HU', 'hy-AM', 'ko-KR', 'pl', 'da', 'pt-PT'];
//localeFile = "settings.json";
// t();
//translateHelpPage();
translateHelpPage();
//translatePage();
// translateAll("mboximport.properties", translationArray, options);
translateAll(inputFiles, translationArray, options);
//loadTranslationArray(inputFiles, options);
//console.log(translationArray.length)
//translationArray = translationArray.slice(101)
//translateAll("messages.json", translationArray, options);
//translateAll(inputFiles, translationArray, options);
//loadTranslationArray(inputFiles, options);
//convert(inputFiles, options);

//locs()
// let inputFiles = ["settings.dtd"];
/*
node .\scripts\translate-gc.js
Expand Down
Loading

0 comments on commit c9d0470

Please sign in to comment.