-
Notifications
You must be signed in to change notification settings - Fork 45
Parameterized Messages #258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for an in-depth look into the EBNF :) Terms are meant to be private and stay private, so changing The primary use-case is to allow localizers to define glossary terms. Take the following Italian example: -sync-brand-name = {$capitalization ->
*[uppercase] Account Firefox
[lowercase] account Firefox
}
sync-dialog-title = {-sync-brand-name}
sync-signedout-account-title =
Connetti il tuo {-sync-brand-name(capitalization: "lowercase")} Thanks to the term being private and impossible to reference from the outside of the file, the localizer is in total control of it. If they decide to change the default variant to the -sync-brand-name = {$capitalization ->
[uppercase] Account Firefox
*[lowercase] account Firefox
}
sync-dialog-title = {-sync-brand-name(capitalization: "uppercase")}
sync-signedout-account-title =
Connetti il tuo {-sync-brand-name)} In both scenarios, calling Let me know what you think about this. Perhaps this is more of a documentation issue? https://projectfluent.org/fluent/guide/terms.html could do a better job of explaining the reasoning behind terms being private. |
That makes sense. The particular point that I was missing (and which could be improved in the documentation) was that terms are explicitly controlled by the localizer. One aspect of Fluent that I'm starting to like is that it's got thought put into its use from the localizer's point of view, separately from the developer, and that it's opinionated about the scope of the solutions it's covering. In particular, fixing the file format makes a lot of sense, as it's something that e.g. ICU MessageFormat leaves out of its scope. |
I have no idea if this is a good practice, but I do find a GitHub issue related to this. REF: projectfluent/fluent#258
* feat: Experimental i18n * chore: Add missing license header * refactor: Use fluent.runtime internal API * feat: Testing i18n inside the bot * feat: Test with different language * feat: Add different way to set locale * test: Further i18n testing * docs: Remove i18n from TODO [skip ci] * feat: List out every locales on init Should allow the bot the get accurate list of available locales * feat: Use the i18n on the bot * refactor(i18n): Better typehint support * fix: Don't use isolating in FluentBundle * test: Handle i18n in tests * chore: Turn i18n into async * docs: README * feat: Support slash * fix(i18n): Default command name * chore: Update fluent * fix: Handle locale_str in help command * chore: Change `brief` -> `description`, `description` -> `help` This will help supporting i18n easier since AppCommands only has short description and has no such thing as brief and long description * locale: Fix inconsistent command name * fix: Wrong locale code * feat(i18n): Shortcuts for locale_str in Context * locale: Fix another inconsistency * locale: (Partially) translated `exts.admin` * locale: Improve id translation * locale: (Partially) translated anilist * locale: Translate admin commands' arguments * locale: (Partially) translated fun * locale: (Partially) translated info * locale: (Partially) translated meta * locale: Translated NSFW * locale: (Partially) translated timer * locale: (Partially) translated utilities * fix: Invalid locale message id * fix: Typo * feat: Custom `@command` and `@group` decorator * locale: Japanese * locale: Translated log config handler I have no idea if this is a good practice, but I do find a GitHub issue related to this. REF: projectfluent/fluent#258 * feat: WIP i18n friendly embed builder * feat: WIP i18n-compatible Embed Builder * locale: Translated admin * fix: Fix locale * fix: Role set title use the wrong locale key * locale: Translated anilist * fix: Cog page still use short_doc instead of description * fix: Flag raise error * locale: Translate fun * fix: Reddit colour is not used in loading message * locale: Translate coin flip * locale: Add missing translation and fix error * locale: Translate info * fix: Brain fart, should be 'result =' not 'return' * locale: Remove ERROR prefix * locale: Remove ERROR prefix * locale: Translate meta * fix: Quick embed fields * locale: Translate the rest of the commands * fix: Embed fields become singleton for some reason * fix: Invalid message id * test: Fix test unit * fix: Open ftl files with utf8 encoding * feat: Port ZEmbed shortcuts to ZEmbedBuilder * chore: Simplify admin codes * chore: Stop pyright from yelling me about property setter * chore: Merge greeting properly * fix: Extension load/reload doesn't work * fix: Duplicate function * chore: Add `Users` model and add locale column to `GuildConfigs` model * docs: Accidentally revert README.md changes * chore: Improve typehint * docs: i18n update * revert: Revert "chore: Improve typehint" This reverts commit 0fd838f.
Reading through the BNF, I was surprised by this:
fluent/spec/fluent.ebnf
Lines 67 to 68 in aa89b97
Having then read through some of the history (In particular #176 and this comment on #80), I think I sort of understand the reasoning here, but I believe in actual use it could still prove rather surprising.
The usage pattern I have in mind here is first implementing a parameterised term, and later having a need for using that term directly as a message. In that situation, replacing
-term
withterm
in messages won't work, as{term(foo:"bar")}
is not valid syntax.If there's a longer-term intent of differentiating the capabilities of terms and messages more, then this difference makes sense. As is it seems to be the only thing that you can do with a term but not with a message, and that's a bit odd.
The text was updated successfully, but these errors were encountered: