Skip to content
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

Request Feature: Support prefix identifier for message #624

Open
ngdangtu-vn opened this issue Nov 28, 2023 · 6 comments
Open

Request Feature: Support prefix identifier for message #624

ngdangtu-vn opened this issue Nov 28, 2023 · 6 comments

Comments

@ngdangtu-vn
Copy link

ngdangtu-vn commented Nov 28, 2023

I would like to ask if it is possible to do so? Currently I'm implementing Fluent to Lume: https://gitlab.com/ndt-deno/lume-fluent

So far it's all good. But in future, I would like to make a scope feature base on fluent file name. I was thinking it would be great if I can get fluent file name and turn it into prefix of every message. But FluentBundle doesn't seems to support it. I wonder if it's make sense (and ok) to you guys to have that feature in the lib?

Maybe an option in FluentResource would be cool:

new FluentResource('msg-id = a message ID', { namespace: 'prefix' })

The result will be prefix-msg-id. How was that?

@ngdangtu-vn
Copy link
Author

Also, may I ask why we wrap a whole parse inside the FluentResource class constructor? Can we use private method if we don't want it to get exposed?

@zbraniecki
Copy link
Collaborator

But FluentBundle doesn't seems to support it.

The idea behind the bundle is that it can be composed of files from many sources.
In other words, a message with id foo can be provided by either file menus.ftl or common.ftl. Your request for prefixes would not work with that.

It may be useful for different models than we planned.

may I ask why we wrap a whole parse inside the FluentResource class constructor?

Intentional as well. You're not supposed to handle AST in runtime.

@ngdangtu-vn
Copy link
Author

Can we add prefix on FluentResource?

new FluentResource('msg-id = a message ID', { namespace: 'prefix' })

Intentional as well. You're not supposed to handle AST in runtime.

Ok, cool.

@stasm
Copy link
Contributor

stasm commented Nov 29, 2023

FluentResource was written a long time ago, when private methods didn't exist in JS. Today, moving the parsing logic to a private method would probably make sense.

@ngdangtu-vn
Copy link
Author

FluentResource was written a long time ago, when private methods didn't exist in JS. Today, moving the parsing logic to a private method would probably make sense.

I think I can do that, if you don't mind.

@stasm
Copy link
Contributor

stasm commented Nov 29, 2023

CC @eemeli, who leads the development of Fluent.

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

No branches or pull requests

3 participants