Internationalization / Localization

24 views
Skip to first unread message

Alan Smith

unread,
Oct 2, 2025, 12:57:57 PM (20 hours ago) Oct 2
to blo...@googlegroups.com
We are running into a problem where our typical i18n library takes things in the format of "A localized string about {{item}}" where blockly wants it like "A localized string about %1"

It is much easier for our translators to handle the first than the second.   We can put our blockly msg where it is "A localized string about {{item}}" but then we have to write our own replace method to replace the token.

Is there a better way to do this that we have just missed?   If not, let me know if an issue of supporting the i18n format has any chance of being accepted.

Thanks,

Alan

Maribeth Moffatt

unread,
Oct 2, 2025, 3:30:13 PM (18 hours ago) Oct 2
to Blockly
Can you share a little bit more about the context for these translations?

Are these for the built-in messages where you're translating the built-in messages on your own and not using the translations we provide? If so that is a bit trickier. We are not likely to change our message format for built-in strings. But we can think together about a solution if this is the scenario you're in.

Are these for your own new messages, such as in custom blocks? I think, but I'm not 100% certain, that Blockly never calls `.replace('%1', ...)` on a developer-provided message. So you can use a different token if you want, and call `.replace` with your own token. That's just the built-in javascript string replace method replacing the token we chose in our messages, we're not doing anything i18n-specific here, so you should be able to replace a different token of your choosing if you'd like.

Let me know if that helps or not. Best,
Maribeth

محمد محمد

unread,
Oct 2, 2025, 4:20:20 PM (17 hours ago) Oct 2
to blo...@googlegroups.com


في الخميس، ٢ أكتوبر ٢٠٢٥ ١٠:٣١ م محمد محمد <ytrewq7...@gmail.com> كتب:

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/blockly/7621dbdd-3681-41ea-aa1a-aa6b2631851en%40googlegroups.com.

محمد محمد

unread,
Oct 2, 2025, 4:20:20 PM (17 hours ago) Oct 2
to blo...@googlegroups.com
في الخميس، ٢ أكتوبر ٢٠٢٥ ١٠:٣٠ م 'Maribeth Moffatt' via Blockly <blo...@googlegroups.com> كتب:

Alan Smith

unread,
Oct 2, 2025, 4:35:31 PM (17 hours ago) Oct 2
to blo...@googlegroups.com
Maribeth,
   You are exactly right.  This is for messages on custom blocks, custom tooltips, custom warning messages, etc.    The way we are doing it right now is that we have a tokens.ts file that has all of our strings and they look like t('some message here') on the value portion so that it then goes on to our internationalization library.    

To make it less abstract, this is where we define our tokens: https://github.com/wpilibsuite/systemcore-blocks-interface/blob/main/src/blocks/tokens.ts

When we change the blockly locale, we first call it with the built-in locale and then we add our own by passing in the function in the file mentioned above.


Today, we are doing like you describe (we use our own token and call .replace), and I just wanted to make sure there wasn't a better way.

Thanks,

Alan


Maribeth Moffatt

unread,
Oct 2, 2025, 5:51:01 PM (15 hours ago) Oct 2
to Blockly
No, that sounds reasonable to me for custom blocks. You're essentially doing the same thing we do, just with a custom replacement string instead of `%1`.

Best,
Maribeth

Reply all
Reply to author
Forward
0 new messages