__init__.py 1016 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # @package ext
  2. __doc__ = """
  3. Yiddish transliteration module.
  4. Courtesy of Isaac Bleaman and Asher Lewis.
  5. https://github.com/ibleaman/yiddish.git
  6. Note the underscore in the module name to disambiguate with the `yiddish`
  7. external package name.
  8. """
  9. from yiddish import detransliterate, transliterate
  10. from scriptshifter.exceptions import BREAK
  11. from scriptshifter.tools import capitalize
  12. def s2r_post_config(ctx):
  13. """
  14. Script to Roman.
  15. """
  16. rom = transliterate(
  17. ctx.src, loc=True,
  18. loshn_koydesh=ctx.options.get("loshn_koydesh"))
  19. if ctx.options["capitalize"] == "all":
  20. rom = capitalize(rom)
  21. elif ctx.options["capitalize"] == "first":
  22. rom = rom[0].upper() + rom[1:]
  23. ctx.dest = rom
  24. return BREAK
  25. def r2s_post_config(ctx):
  26. """
  27. Roman to script.
  28. NOTE: This doesn't support the `loc` option.
  29. """
  30. ctx.dest = detransliterate(
  31. ctx.src,
  32. loshn_koydesh=ctx.options.get("loshn_koydesh"))
  33. return BREAK