Unverified Commit d16af738 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #8796 from DonLakeFlyer/Translations

Json Translations
parents 475fbf32 513ad234
files: "files": [
- source: /translations/qgc.ts {
translation: /translations/qgc_%locale_with_underscore%.ts "source": "/translations/qgc.ts",
"translation": "/translations/qgc_%locale_with_underscore%.ts"
},
{
"source": "/translations/qgc-json.ts",
"translation": "/translations/qgc_%locale_with_underscore%.ts"
},
]
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
QGC uses the standard Qt Linguist mechanisms for string translation. QGC uses crowd sourced string translation through a [Crowdin project](https://crowdin.com/project/qgroundcontrol for translation). QGC uses the standard Qt Linguist mechanisms for string translation. QGC uses crowd sourced string translation through a [Crowdin project](https://crowdin.com/project/qgroundcontrol for translation).
## `source qgc-lupdate.sh`
Run this command to update the translations files for both Qt and Json. Crowdin will automatically pull these up and submit a pull request back when new translations are available.
## C++ and Qml code strings ## C++ and Qml code strings
These are coded using the standard Qt tr() for C++ and qsTr() for Qml mechanisms. These are coded using the standard Qt tr() for C++ and qsTr() for Qml mechanisms.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -86,17 +86,11 @@ def walkDirectoryTreeForJsonFiles(dir, multiFileLocArray): ...@@ -86,17 +86,11 @@ def walkDirectoryTreeForJsonFiles(dir, multiFileLocArray):
if (os.path.isdir(path)): if (os.path.isdir(path)):
walkDirectoryTreeForJsonFiles(path, multiFileLocArray) walkDirectoryTreeForJsonFiles(path, multiFileLocArray)
def appendToQGCTSFile(multiFileLocArray): def writeJsonTSFile(multiFileLocArray):
originalTSFile = codecs.open('qgc.ts', 'r', "utf-8") jsonTSFile = codecs.open('qgc-json.ts', 'w', "utf-8")
newTSFile = codecs.open('qgc.ts.new', 'w', "utf-8")
line = originalTSFile.readline()
while (line != "</TS>\n"):
newTSFile.write(line);
line = originalTSFile.readline()
originalTSFile.close()
for entry in multiFileLocArray: for entry in multiFileLocArray:
newTSFile.write("<context>\n") jsonTSFile.write("<context>\n")
newTSFile.write(" <name>%s</name>\n" % entry[0]) jsonTSFile.write(" <name>%s</name>\n" % entry[0])
singleFileLocStringDict = entry[2] singleFileLocStringDict = entry[2]
for locStr in singleFileLocStringDict.keys(): for locStr in singleFileLocStringDict.keys():
disambiguation = "" disambiguation = ""
...@@ -108,25 +102,25 @@ def appendToQGCTSFile(multiFileLocArray): ...@@ -108,25 +102,25 @@ def appendToQGCTSFile(multiFileLocArray):
sys.exit(1) sys.exit(1)
disambiguation = workStr[:terminatorIndex] disambiguation = workStr[:terminatorIndex]
locStr = workStr[terminatorIndex+1:] locStr = workStr[terminatorIndex+1:]
newTSFile.write(" <message>\n") jsonTSFile.write(" <message>\n")
if len(disambiguation): if len(disambiguation):
newTSFile.write(" <comment>%s</comment>\n" % disambiguation) jsonTSFile.write(" <comment>%s</comment>\n" % disambiguation)
extraCommentStr = "" extraCommentStr = ""
for jsonHierachy in singleFileLocStringDict[locStr]: for jsonHierachy in singleFileLocStringDict[locStr]:
extraCommentStr += "%s, " % jsonHierachy extraCommentStr += "%s, " % jsonHierachy
newTSFile.write(" <extracomment>%s</extracomment>\n" % extraCommentStr) jsonTSFile.write(" <extracomment>%s</extracomment>\n" % extraCommentStr)
newTSFile.write(" <location filename=\"%s\"/>\n" % entry[1]) jsonTSFile.write(" <location filename=\"%s\"/>\n" % entry[1])
newTSFile.write(unicode(" <source>%s</source>\n") % locStr) jsonTSFile.write(unicode(" <source>%s</source>\n") % locStr)
newTSFile.write(" <translation type=\"unfinished\"></translation>\n") jsonTSFile.write(" <translation type=\"unfinished\"></translation>\n")
newTSFile.write(" </message>\n") jsonTSFile.write(" </message>\n")
newTSFile.write("</context>\n") jsonTSFile.write("</context>\n")
newTSFile.write("</TS>\n") jsonTSFile.write("</TS>\n")
newTSFile.close() jsonTSFile.close()
def main(): def main():
multiFileLocArray = [] multiFileLocArray = []
walkDirectoryTreeForJsonFiles("../src", multiFileLocArray) walkDirectoryTreeForJsonFiles("../src", multiFileLocArray)
appendToQGCTSFile(multiFileLocArray) writeJsonTSFile(multiFileLocArray)
if __name__ == '__main__': if __name__ == '__main__':
main() main()
#!/bin/bash
# This script will update both the Qt and Json string translation files.
QT_PATH=~//Qt/5.12.6/gcc_64/bin
rm qgc-qt.ts
$QT_PATH/lupdate ../src -ts qgc.ts
python qgc-lupdate-json.py
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment