Skip to content

feat: add Brazilian Portuguese dictionary and language selection - #118

Open
amelotti wants to merge 3 commits into
bartificer:mainfrom
amelotti:feat/dictionary-ptbr
Open

feat: add Brazilian Portuguese dictionary and language selection#118
amelotti wants to merge 3 commits into
bartificer:mainfrom
amelotti:feat/dictionary-ptbr

Conversation

@amelotti

Copy link
Copy Markdown

Summary

Add support for multiple dictionary languages, starting with Brazilian Portuguese (PT-BR).

Changes

  • Add DictionaryPTBR class with ~710 common Portuguese words (no accented characters for password system compatibility)
  • Add DICTIONARIES registry in XKPasswd for available languages
  • Add setDictionary(language) method for runtime language switching
  • Add getLanguages() method to list supported languages
  • Add 33 new unit tests (all 155 tests pass)

Usage

const xk = new XKPasswd();
xk.setDictionary('PT-BR');
const { passwords } = xk.generatePassword(3);

Design Decisions

  • Architecture uses a registry pattern, making it easy to add more languages in the future
  • Language switching is independent of preset selection
  • No breaking changes to existing API

amelotti added 3 commits July 10, 2026 16:38
Add DictionaryPTBR class with ~710 Portuguese words suitable for
password generation. Words include Brazilian place names and common
Portuguese nouns, verbs, and adjectives.

No accented characters are used to maintain compatibility with
password input systems.
Add DICTIONARIES registry mapping language codes to dictionary classes.
Add setDictionary(language) method to switch between available
dictionaries at runtime. Add getLanguages() to list supported languages.

Currently supported: EN (English), PT-BR (Brazilian Portuguese).
Add 20 unit tests for DictionaryPTBR covering instantiation,
word list validation, word length bounds, word() method, and
filteredWordList().

Add 13 tests for language selection covering getLanguages(),
setDictionary() validation, password generation with PT-BR,
preset+language interaction, and language switching.
@amelotti
amelotti marked this pull request as ready for review July 10, 2026 20:11
@bbusschots

Copy link
Copy Markdown
Contributor

@amelotti this looks like a lot of really great work — thanks!

@hepabolu — can you give this a once-over, and then merge it if you're happy?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants