mirror of
https://github.com/pstrueb/piper.git
synced 2026-05-09 23:08:01 +00:00
Added accessibility voice guides for notebook.
This commit is contained in:
27
notebooks/translator.py
Normal file
27
notebooks/translator.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import configparser
|
||||||
|
import os
|
||||||
|
|
||||||
|
class Translator:
|
||||||
|
def __init__(self):
|
||||||
|
self.configs = {}
|
||||||
|
|
||||||
|
def load_language(self, language_name):
|
||||||
|
if language_name not in self.configs:
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read(os.path.join(os.getcwd(), "lng", f"{language_name}.lang"))
|
||||||
|
self.configs[language_name] = config
|
||||||
|
|
||||||
|
def translate(self, language_name, string):
|
||||||
|
if language_name == "en":
|
||||||
|
return string
|
||||||
|
elif language_name not in self.configs:
|
||||||
|
self.load_language(language_name)
|
||||||
|
config = self.configs[language_name]
|
||||||
|
try:
|
||||||
|
return config.get("Strings", string)
|
||||||
|
except (configparser.NoOptionError, configparser.NoSectionError):
|
||||||
|
if string:
|
||||||
|
return string
|
||||||
|
else:
|
||||||
|
raise Exception("language engine error: This translation is corrupt!")
|
||||||
|
return 0
|
||||||
BIN
notebooks/wav/en/downloaded.wav
Normal file
BIN
notebooks/wav/en/downloaded.wav
Normal file
Binary file not shown.
BIN
notebooks/wav/en/downloading.wav
Normal file
BIN
notebooks/wav/en/downloading.wav
Normal file
Binary file not shown.
BIN
notebooks/wav/en/dwnerror.wav
Normal file
BIN
notebooks/wav/en/dwnerror.wav
Normal file
Binary file not shown.
BIN
notebooks/wav/en/exit.wav
Normal file
BIN
notebooks/wav/en/exit.wav
Normal file
Binary file not shown.
BIN
notebooks/wav/en/installed.wav
Normal file
BIN
notebooks/wav/en/installed.wav
Normal file
Binary file not shown.
BIN
notebooks/wav/en/installing.wav
Normal file
BIN
notebooks/wav/en/installing.wav
Normal file
Binary file not shown.
BIN
notebooks/wav/en/multispeaker.wav
Normal file
BIN
notebooks/wav/en/multispeaker.wav
Normal file
Binary file not shown.
BIN
notebooks/wav/en/nomodel.wav
Normal file
BIN
notebooks/wav/en/nomodel.wav
Normal file
Binary file not shown.
BIN
notebooks/wav/en/novoices.wav
Normal file
BIN
notebooks/wav/en/novoices.wav
Normal file
Binary file not shown.
BIN
notebooks/wav/es/donwloading.wav
Normal file
BIN
notebooks/wav/es/donwloading.wav
Normal file
Binary file not shown.
BIN
notebooks/wav/es/downloaded.wav
Normal file
BIN
notebooks/wav/es/downloaded.wav
Normal file
Binary file not shown.
BIN
notebooks/wav/es/dwnerror.wav
Normal file
BIN
notebooks/wav/es/dwnerror.wav
Normal file
Binary file not shown.
BIN
notebooks/wav/es/exit.wav
Normal file
BIN
notebooks/wav/es/exit.wav
Normal file
Binary file not shown.
BIN
notebooks/wav/es/installed.wav
Normal file
BIN
notebooks/wav/es/installed.wav
Normal file
Binary file not shown.
BIN
notebooks/wav/es/installing.wav
Normal file
BIN
notebooks/wav/es/installing.wav
Normal file
Binary file not shown.
BIN
notebooks/wav/es/multispeaker.wav
Normal file
BIN
notebooks/wav/es/multispeaker.wav
Normal file
Binary file not shown.
BIN
notebooks/wav/es/nomodel.wav
Normal file
BIN
notebooks/wav/es/nomodel.wav
Normal file
Binary file not shown.
BIN
notebooks/wav/es/novoices.wav
Normal file
BIN
notebooks/wav/es/novoices.wav
Normal file
Binary file not shown.
Reference in New Issue
Block a user