Blockly localization (i18n)

831 views
Skip to first unread message

Hilty

unread,
Apr 17, 2017, 4:37:08 AM4/17/17
to Blockly
Hi Guys,

How I can localize the Blockly texts?
I try to find it in documentation but I don't find it. 
Please could someone help me?

Thanks for all,
Cheers,

Cory Diers

unread,
Apr 17, 2017, 12:26:04 PM4/17/17
to blo...@googlegroups.com

Hey Hilty,

Internationalization of blocks can be done easily by specifying the appropriate message file for your language. Somewhere in your code (likely in index.html,) there should be a messages file:
<script src="msg/js/en.js"></script>
In this example, it's english (en.js). Simply replace that with the desired language,  like this:
<script src="msg/js/fr.js"></script>
That would change the block language to French. The message files we provide are found here: https://github.com/google/blockly/tree/master/msg/js

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Cory Diers | Software Engineer | cory...@google.com | 

Hebert Phillipe

unread,
Apr 17, 2017, 7:07:59 PM4/17/17
to blo...@googlegroups.com
Hi Cory, 

Thanks for your reply. :-)

But what if I need to change the texts inside a custom block? 
Maybe turn a "Create a Bird" (english) text inside a custom block for "Crie um passaro" (portuguese), for example.

Thanks for all,
Cheers,





--
Cory Diers | Software Engineer | corydiers@google.com | 

--
You received this message because you are subscribed to a topic in the Google Groups "Blockly" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/blockly/uraab7pmyGM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to blockly+unsubscribe@googlegroups.com.

Cory Diers

unread,
Apr 17, 2017, 7:56:15 PM4/17/17
to blo...@googlegroups.com
 f you want to use custom text, you'll need to include those properties and their appropriate translations. You can find an example of this in the Blockly Games repository, which defines the messages in their own files, then combines them with the appropriate core Blockly files, in the build script.

If you add strings to the <language>.js file, they can be referenced from block definitions with BKY_<KEY>. 




--
Cory Diers | Software Engineer | cory...@google.com | 

--
You received this message because you are subscribed to a topic in the Google Groups "Blockly" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/blockly/uraab7pmyGM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to blockly+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Cory Diers | Software Engineer | cory...@google.com | 

Andrew n marshall

unread,
Apr 18, 2017, 12:30:48 PM4/18/17
to blo...@googlegroups.com
Just a clarification, I'm pretty sure the %{BKY_<KEY>} notation only works for the JSON notation of blocks. This is our preferred notation going forward. If you're still using the JavaScript calls, use Blockly.Msg.<KEY> or Blockly.Msg["<KEY>"] directly.
Cory Diers | Software Engineer | corydiers@google.com | 

Message has been deleted
Message has been deleted

Andrew n marshall

unread,
Mar 30, 2018, 6:06:11 PM3/30/18
to blo...@googlegroups.com
The Android version doesn't have made localization implemented. The JSON block definitions have the raw strings. You will need to replace each of those. This could probably be scripted.

Or implement localization support that takes in the localization .JSON file. We take pull requests.

On Fri, Mar 30, 2018, 12:52 PM 韩建飞 <melody...@gmail.com> wrote:
Hi, Cory
thank you for your answer.
It is useful.
but, my project is Andorid demo of blockly. 
I replace the en.js with zh-hans.js, but the text of the block is not changed.
And I think maybe the zh-hans.json isn't used,
Where should I replace it or add it ?

在 2017年4月18日星期二 UTC+8上午12:26:04,Cory Diers写道:

Hey Hilty,

Internationalization of blocks can be done easily by specifying the appropriate message file for your language. Somewhere in your code (likely in index.html,) there should be a messages file:
<script src="msg/js/en.js"></script>
In this example, it's english (en.js). Simply replace that with the desired language,  like this:
<script src="msg/js/fr.js"></script>
That would change the block language to French. The message files we provide are found here: https://github.com/google/blockly/tree/master/msg/js
On Mon, Apr 17, 2017 at 1:37 AM, Hilty <hilty.c...@gmail.com> wrote:
Hi Guys,

How I can localize the Blockly texts?
I try to find it in documentation but I don't find it. 
Please could someone help me?

Thanks for all,
Cheers,

--
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.

For more options, visit https://groups.google.com/d/optout.



--
Cory Diers | Software Engineer | cory...@google.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.
Reply all
Reply to author
Forward
0 new messages