Skip to content

Make it possible to deprecate translated section headers and settings #5668

Closed

Description

@pekkaklarck

RF 6.0 added support for translating markers used in the data (#4096). In practice that meant section headers, settings, BDD prefixes and true/false strings.

The system has worked fine, but it has a problem that there's no way to change a translation without breaking existing tests/tasks using the old term. For example, we have an issue about changing French test case section header from "Unités de test" to "Cas de test" (#5510), and just changing the term would break all existing test using the "Unités de test". Before we can make that change, we need to have a way to deprecate translations so that the old term still works.

Although changing any translation would be a backwards incompatible change, I believe we can concentrate on section headers and settings in this issue for the following reasons:

  • BDD prefixes and true/false strings are defined as lists. This means that new values can be safely added as long as old ones aren't removed. For example, we added new French BDD prefixes in RF 7.3 (Enhance BDD support (GIVEN/WHEN/THEN) for French language #5150).
  • Deprecation removal of BDD prefixes or true/false strings requires slightly different approach than deprecation direct replacements.
  • There are no concrete needs to remove BDD prefixes or true/false strings. We can return to this if such needs arise.

Although the basic idea is pretty simple, there are various design decisions to be made. I'll write separate comments about the.


UPDATE: The mechanism to deprecate headers and settings is implemented in Robot Framework 7.5, but deprecation warnings are never emitted. That is due to reporting warnings, not only errors, during parsing is somewhat complicated and the related issue (#5210) was descoped to RF 7.6. Deprecations can be added already now and old and new term both work. This makes it possible to implement #5510.

Activity

  1. added this to the v7.5 milestone on May 6, 2026
  2. self-assigned this
    on May 6, 2026
  3. pekkaklarck commented on May 6, 2026

    @pekkaklarck
    MemberAuthor

    Design decision 1: How users should be able to mark depreacations?

    A simple approach is adding new class attribute deprecations: dict[str, str] = {} to the Language class. The dict would map old terms to new ones, and we could emit a deprecation warning if an old term is used.

    Although the idea is to allow deprecation of both section headers and settings, I believe having one deprecations dictionary is fine. We obviously need to know is the deprecated term a header or a setting, but we can easily check that internally. There would be problems if someone had used same term both as a header and as a setting, but I don't consider that likely enough to warrant making the usage more complicated.

    As an example, with the French test case header (#5510) the only things needed would be changing the current

    test_cases_header = "Unités de test"

    to

    test_cases_header = "Cas de test"

    and adding

    deprecations = {"Unités de test": "Cas de test"}

    Then we could eventually remove the entry from the deprecations dictionary.


    UPDATE: We decided to use (term, version) tuples as dictionary values. See comments below for details.

  4. pekkaklarck commented on May 6, 2026

    @pekkaklarck
    MemberAuthor

    Design decision 2: Can we deprecate terms immediately?

    If we just add deprecations: dict[str, str] = {} that users can update, deprecation starts immediately when an entry is added to this dictionary. That is obviously a lot better than just changing the term which would break existing tests, but it is nevertheless somewhat annoying if, for example, in RF 7.4 you can only use "Unités de test" and in RF 7.5 you get a deprecation warning if you use that instead of "Cas de test".

    When deprecating something, I in general prefer having a "soft deprecation" period where you can use both the new and the old functionality without a deprecation warning. With out example, it would mean that both "Unités de test" and "Cas de test" would work in RF 7.5 without a deprecation warning, but in the next version there would be one if the former is used. "Unités de test" would also be marked deprecated in the RF 7.5 release notes and in the User Guide.

    The problem with a soft deprecation period is that the first version when something has been deprecated would need to be known. One possibility would be something like this:

    deprecations = {"Unités de test": ("Cas de test", "7.5")}

    This makes the usage a little bit more complicated and also makes the implementation of this feature a bit harder. It would have a benefit that the version when something has been deprecated could also be shown in the error message as well as in the automatically generated User Guide documentation.

    One problem with including the version information is that custom language files aren't Robot Framework version specific. If you are using them and want to deprecate something, including Robot version is odd and misleading. It's unlikely that custom language files are used widely and that there would be deprecation needs with them, but this certainly needs to be taken into account if we decide to include the version number. Perhaps we could support using None as a version number when it is not relevant.

  5. pekkaklarck commented on May 6, 2026

    @pekkaklarck
    MemberAuthor

    Design decision 3: When to remove deprecated terms?

    Should we decide when a term is removed already when it is deprecated? Being able to mention that in the deprecation messages and showing that in the documentation would be convenient, but there are various problems with it:

    • We don't know what future versions there are going to be. For example, we haven't yet decided is the version after RF 7.5 going to be RF 7.6 or RF 8.0. Removing deprecated terms only in major versions would help here, but we don't have stable enough major release cadence to know could something deprecated now be removed already in RF 9.0 or should it wait for RF 10.0.
    • Even if the version when something is to be removed would be in the code, the deprecated term could be removed automatically when the development of that version starts.
    • Including also the removal version would complicate the deprecations dictionary even further.

    Due to the problems listed above, I believe this is not a good idea.

  6. pekkaklarck commented on May 6, 2026

    @pekkaklarck
    MemberAuthor

    Comments about the above design decisions are highly appreciated! My own current thinking is this:

    1. The overall approach to use deprecations dictionary that maps old terms to new ones feels good. I actually have a prototype working locally already.
    2. A soft deprecation period and reporting when something has been deprecated feels convenient, but I'm not sure is it worth the effort.
    3. Specifying when a term is removed makes no sense.
  7. added a commit that references this issue on May 7, 2026
  8. pekkaklarck commented on May 7, 2026

    @pekkaklarck
    MemberAuthor

    This is now implemented so that it is possible to give the version when a term is deprecated. The syntax is this:

    deprecations = {"Unités de test": ("Case de test", "7.5")}

    In addition to adding the deprecated term to the deprecations dictionary, it needs to be replaced with the new term as illustrated above.

    The deprecated term continues to work until it is removed from the deprecations dictionary. Deprecation warnings are emitted starting from the next non-bugfix release after deprecation. For example, if a term is deprecated in version 7.5, there are no deprecation warnings in 7.5.1 or in other 7.5.x releases, but warnings start automatically in 7.6 (or in 8.0 if that is the next release).

    If deprecation is needed with custom language files not tied to Robot Framework versions, version in the deprecations dictionary can be set to None. In that case deprecation warnings are emitted immediately.

  9. pekkaklarck commented on May 7, 2026

    @pekkaklarck
    MemberAuthor

    Although the base implementation is done, the functionality hasn't yet been taken into actual use by the parsing modules. That turned out to be complicated with settings, because parsing modules don't currently differentiate warnings and errors. We already have issue #5210 about enhancing that situation, and its probably best to implement that before finalizing this issue. Deprecating headers would be possible already now, because we could use the same kludge we used to get deprecation warnings about singular section headers shown (#4432).

  10. pekkaklarck commented on May 7, 2026

    @pekkaklarck
    MemberAuthor

    As explained above, this issue needs to wait until #5210 is done. I'll list the open tasks below so that we don't forget them when we return to this issue:

    • Integrate with parsing modules once Support warnings, not only errors, in parsing model #5210 is ready. This requires adding unit and acceptance tests. Support warnings, not only errors, in parsing model #5210 was moved to RF 7.6 so this need to wait was well.
    • Update the script that generates the Translations appendix to the User Guide so that it somehow lists deprecations.
    • Document the deprecation system in the User Guide. It is currently only documented in the API docs of the Language class. The language file syntax isn't documented in the User Guide so documenting how deprecations work makes no sense. There's a link to the source code so interested users/contributors can easily find this information anyway.
  11. changed the title [-]Make it possible to deprecate translated section headers and settings[/-] [+]Make it possible to deprecate translated section headers[/+] on Jul 16, 2026
  12. changed the title [-]Make it possible to deprecate translated section headers[/-] [+]Make it possible to deprecate translated section headers and settings[/+] on Jul 16, 2026
  13. pekkaklarck commented on Jul 16, 2026

    @pekkaklarck
    MemberAuthor

    The functionality to specify deprecations in language files has been implemented. If it is used, both the old and new term continue to work. The idea is to start emitting deprecation warnings in the next release after deprecation, but the mechanism to actually emit these warnings is still not done. The reason is that properly reporting warnings, not only errors, during parsing (#5210) turned out to be complicated, and that issue was moved to RF 7.6. As I already wrote, there were no plans to emit deprecation warnings in RF 7.5, so that doesn't matter with Robot Framework itself. Users with custom language files won't see deprecation warnings either, but I doubt custom files are used much or that there would be actual needs for deprecations.

  14. added a commit that references this issue on Jul 16, 2026
    1b65c5f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions