Skip to content

studyingegret/python-fluent

This branch is 12 commits ahead of, 2 commits behind projectfluent/python-fluent:main.

Folders and files

NameName
Last commit message
Last commit date
Jan 31, 2025
Jan 31, 2025
Mar 18, 2024
Mar 18, 2024
Mar 18, 2024
Jan 31, 2025
Jul 26, 2024
Mar 18, 2024
Mar 18, 2024
Mar 10, 2024
Feb 5, 2019
Jan 31, 2025
Apr 9, 2019
Mar 14, 2017
Feb 8, 2025
Mar 10, 2024
Mar 10, 2024

Repository files navigation

About this fork

An attempt to refactor fluent.runtime.

Notes for whoever is interested in this fork:

  • This section is really outdated, but I don't expect myself to have the time to update it soon.

  • Do not expect my commits to be logical. I am new to developing with GitHub and Git, it feels too distracting and unrealistic for me to commit & message in a way that the message perfectly describes the commit. So often(?) the commit messages only describe the main changes of the commit or one or some of the changes in the commit.

    (Some people commit per file change (?), but it feels too verbose, and I feel I will likely make changes hard to summarize and end up saying very general messages like "Do one thing", "Change files a.py, b.txt" that way, which are too general to be really useful)

  • I am not sure if it is required to use my real name for Git commits. It seems that almost everyone else don't bother using their real name, but I would prefer to keep it secret (if possible).

  • Code will be rewritten if it feels unclear.

Unresolved questions for refactoring:

  • Is the project architecture designed to be same as fluent.js, fluent-rs? If so, do the classes correspond trivially?

    Specifically, what does FluentLocalization correspond to?

  • Should I fix failing tests first? Saw these failures at 17dfdd4c (output of VS Code task "Test fluent.syntax and fluent.runtime") (Python 3.13.1)

    # Test fluent.syntax
    ====================
    ........................................................................................................................................................................................................................................................................
    ----------------------------------------------------------------------
    Ran 264 tests in 0.189s
    
    OK
    
    # Test fluent.runtime
    =====================
    ....................................................................................................................................................E.F.F.D:\study-coding\python-fluent\fluent.runtime\fluent\runtime\types.py:361: UserWarning: FluentDateType option hour12 is not yet supported
      warnings.warn(f"FluentDateType option {k} is not yet supported")
    ................s...............
    ======================================================================
    ERROR: test_bundles (tests.test_fallback.TestLocalization.test_bundles)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\software\Python\Python313\Lib\unittest\mock.py", line 1424, in patched
        return func(*newargs, **newkeywargs)
      File "D:\study-coding\python-fluent\fluent.runtime\tests\test_fallback.py", line 34, in test_bundles
        bundle_de = next(bundles_gen)
    StopIteration
    
    ======================================================================
    FAIL: test_all_exist (tests.test_fallback.TestResourceLoader.test_all_exist)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\software\Python\Python313\Lib\unittest\mock.py", line 1424, in patched
        return func(*newargs, **newkeywargs)
      File "D:\study-coding\python-fluent\fluent.runtime\tests\test_fallback.py", line 64, in test_all_exist
        self.assertEqual(len(resources_list), 1)
        ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
    AssertionError: 0 != 1
    
    ======================================================================
    FAIL: test_one_exists (tests.test_fallback.TestResourceLoader.test_one_exists)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\software\Python\Python313\Lib\unittest\mock.py", line 1424, in patched
        return func(*newargs, **newkeywargs)
      File "D:\study-coding\python-fluent\fluent.runtime\tests\test_fallback.py", line 76, in test_one_exists
        self.assertEqual(len(resources_list), 1)
        ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
    AssertionError: 0 != 1
    
    ----------------------------------------------------------------------
    Ran 186 tests in 0.237s
    
    FAILED (failures=2, errors=1, skipped=1)
    

    However the latest GitHub Actions test on original repo passed.

Project Fluent

This is a collection of Python packages to use the Fluent localization system.

python-fluent consists of these packages:

fluent.syntax

The syntax package includes the parser, serializer, and traversal utilities like Visitor and Transformer. You’re looking for this package if you work on tooling for Fluent in Python.

fluent.runtime

The runtime package includes the library required to use Fluent to localize your Python application. It comes with a Localization class to use, based on an implementation of FluentBundle. It uses the tooling parser above to read Fluent files.

fluent.pygments

A plugin for pygments to add syntax highlighting to Sphinx.

Discuss

We’d love to hear your thoughts on Project Fluent! Whether you’re a localizer looking for a better way to express yourself in your language, or a developer trying to make your app localizable and multilingual, or a hacker looking for a project to contribute to, please do get in touch on the mailing list and the IRC channel.

Get Involved

python-fluent is open-source, licensed under the Apache License, Version 2.0. We encourage everyone to take a look at our code and we’ll listen to your feedback.

About

Python implementation of Project Fluent

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 88.1%
  • Fluent 11.1%
  • Other 0.8%