Skip to content

Commit

Permalink
Update translations
Browse files Browse the repository at this point in the history
- Make existing strings translatable
- Add .mo files to .gitignore
  • Loading branch information
hsbasu committed Jan 1, 2024
1 parent c81d457 commit fc41f7c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
src/SimplePwgen/VERSION
build/*
dist/*
*.mo

# debian build files
.pybuild/*
Expand Down
18 changes: 9 additions & 9 deletions src/SimplePwgen/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def wrapper(*args, **kwargs):
CONFIG_DIR = os.path.expanduser('~/.config/simple-pwgen/')
CONFIG_FILE = os.path.join(CONFIG_DIR+'config.cfg')
UI_PATH = os.path.dirname(os.path.realpath(__file__)) + "/ui/"
methods = ["Default Method", "Diceware Method", "PIN"]
methods = [_("Default Method"), _("Diceware Method"), _("PIN")]


# This is the backend.
Expand Down Expand Up @@ -92,7 +92,7 @@ def load_config(self):
try:
self.gen_method = int(self.config["user"]['generation-method'])
except:
print('User configuration is missing or not readable. Trying default configuration')
print(_('User configuration is missing or not readable. Trying default configuration'))
self.gen_method = int(self.config["default"]['generation-method'])
except KeyError:
self.gen_method = 0
Expand All @@ -111,7 +111,7 @@ def load_config(self):
self.symbol_num = int(self.config["user"]['symbol_num'])
self.excludeSymbol = self.config["user"]['excludeSymbol']
except:
print('User configuration is missing or not readable. Trying default configuration')
print(_('User configuration is missing or not readable. Trying default configuration'))
self.pwlength = int(self.config["default"]['pwlength'])
self.lowercase = int(self.config["default"]['lowercase'])
self.lowercase_num = int(self.config["default"]['lowercase_num'])
Expand Down Expand Up @@ -162,30 +162,30 @@ def check_config(self):
min_required_length = 0
if self.lowercase == True:
if self.lowercase_num == 0:
print("Warning: minimum number of lowercases should be greater than 0")
print(_("Warning: minimum number of lowercases should be greater than 0"))
else:
min_required_length += self.lowercase_num

if self.uppercase == True:
if self.uppercase_num == 0:
print("Warning: minimum number of UPPERcases should be greater than 0")
print(_("Warning: minimum number of UPPERcases should be greater than 0"))
else:
min_required_length += self.uppercase_num

if self.digit == True:
if self.digit_num == 0:
print("Warning: minimum number of Digits should be greater than 0")
print(_("Warning: minimum number of Digits should be greater than 0"))
else:
min_required_length += self.digit_num

if self.symbol == True:
if self.symbol_num == 0:
print("Warning: minimum number of Symbols should be greater than 0")
print(_("Warning: minimum number of Symbols should be greater than 0"))
else:
min_required_length += self.symbol_num

if min_required_length > self.pwlength:
print("Error: Minimum required length exceeded given length!")
print(_("Error: Minimum required length exceeded given length!"))

return 1

Expand Down Expand Up @@ -427,7 +427,7 @@ def check_pwstrength(self, passwd):
return [score, comment, color]

def check_pwentrpy(self, passwd):
strength_comment = ["Very Weak", "Weak", "Reasonable", "Fairly Strong", "Strong", "Very Strong", "Super Strong"]
strength_comment = [_("Very Weak"), _("Weak"), _("Reasonable"), _("Fairly Strong"), _("Strong"), _("Very Strong"), _("Super Strong")]
length = len(passwd)
pool_size = len(self.pool)
entropy = length*math.log2(pool_size)
Expand Down
20 changes: 10 additions & 10 deletions src/SimplePwgen/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
gettext.textdomain(APP)
_ = gettext.gettext

description = 'Very simple Python3-based GUI application to generate secure and random password.'
description =_('Very simple Python3-based GUI application to generate secure and random password.')

# Parse arguments
parser = argparse.ArgumentParser(prog=APP, description=description, conflict_handler='resolve')

parser.add_argument('-g', '--gui', action='store_true', dest='start_window', default=False, help=("Start GUI window"))
parser.add_argument('-V', '--version', action='store_true', dest='show_version', default=False, help=("Show version and exit"))
parser.add_argument('-g', '--gui', action='store_true', dest='start_window', default=False, help=_("Start GUI window"))
parser.add_argument('-V', '--version', action='store_true', dest='show_version', default=False, help=_("Show version and exit"))

args = parser.parse_args()

Expand All @@ -64,14 +64,14 @@ def start_SPGCli():
[pw_strength, pw_entropy, num_guess_crack, timerq_crack] = generator.check_pwentrpy(ferVar.decrypt(encpasswd).decode())

print("")
print("Generated Password: "+str(ferVar.decrypt(encpasswd).decode()))
print(_("Generated Password: ")+str(ferVar.decrypt(encpasswd).decode()))
print("")
print("Strength: "+str(pw_strength))
print("Score: "+str(pw_score))
print("Entropy: "+str(pw_entropy))
print("Number of Guesses: "+str(num_guess_crack))
print("Time required to crack: "+str(timerq_crack))
print("Comment: "+str(pw_comment))
print(_("Strength: ")+str(pw_strength))
print(_("Score: ")+str(pw_score))
print(_("Entropy: ")+str(pw_entropy))
print(_("Number of Guesses: ")+str(num_guess_crack))
print(_("Time required to crack: ")+str(timerq_crack))
print(_("Comment: ")+str(pw_comment))
print("")

if args.start_window:
Expand Down

0 comments on commit fc41f7c

Please sign in to comment.