Skip to content

Implement different languages in website#2275

Open
HardikMathur11 wants to merge 1 commit into
ergoplatform:masterfrom
HardikMathur11:Languages
Open

Implement different languages in website#2275
HardikMathur11 wants to merge 1 commit into
ergoplatform:masterfrom
HardikMathur11:Languages

Conversation

@HardikMathur11
Copy link
Copy Markdown

Hackathon

This contribution is submitted as part of the Unstoppable Hackathon.


Summary

This PR fixes issues where non-English mnemonic wordlists were not loading reliably at runtime due to classpath and resource resolution limitations. It also adds comprehensive unit tests to ensure all supported languages load correctly and that language-specific behavior (such as Japanese delimiters) is preserved.


Problem

The WordList implementation relied solely on getClass.getResourceAsStream for loading wordlist resources.
This approach can fail in certain environments (e.g., fat JARs, different classloaders, test runners), leading to missing mnemonic wordlists for languages such as Japanese, Chinese, and Korean.


Solution

  • Hardened resource loading in WordList.resourceLoader by:
    • Attempting getClass.getResourceAsStream
    • Falling back to the thread context classloader
    • Falling back to the system classloader
    • Throwing a clear IllegalArgumentException if the resource is not found
  • Added comprehensive unit tests in WordListSpec to:
    • Verify all supported languages load exactly 2048 words
    • Confirm Japanese mnemonics use the ideographic space (\u3000) delimiter
    • Ensure mnemonic generation works for a fixed entropy across all languages

Files Changed

  • ergo-wallet/src/main/scala/org/ergoplatform/wallet/mnemonic/WordList.scala
    • Added robust multi-classloader fallback for loading /wordlist/*.txt
    • Improved error reporting when resources are missing
  • ergo-wallet/src/test/scala/org/ergoplatform/wallet/mnemonic/WordListSpec.scala
    • Added tests for wordlist loading, delimiter correctness, and mnemonic generation

Verification

  • Ran wallet tests:
    sbt "project ergo-wallet" test

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.

1 participant