﻿<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=%E5%88%A9%E7%94%A8%E8%80%85%3AXiaoxiangquan%2FGoogleSummerOfCode%2F2011%2FInternationalization%2Fnotes_for_developers</id>
	<title>利用者:Xiaoxiangquan/GoogleSummerOfCode/2011/Internationalization/notes for developers - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=%E5%88%A9%E7%94%A8%E8%80%85%3AXiaoxiangquan%2FGoogleSummerOfCode%2F2011%2FInternationalization%2Fnotes_for_developers"/>
	<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Xiaoxiangquan/GoogleSummerOfCode/2011/Internationalization/notes_for_developers&amp;action=history"/>
	<updated>2026-04-21T17:02:58Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Xiaoxiangquan/GoogleSummerOfCode/2011/Internationalization/notes_for_developers&amp;diff=106799&amp;oldid=prev</id>
		<title>Yamyam: 1版 をインポートしました</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Xiaoxiangquan/GoogleSummerOfCode/2011/Internationalization/notes_for_developers&amp;diff=106799&amp;oldid=prev"/>
		<updated>2018-06-28T19:46:00Z</updated>

		<summary type="html">&lt;p&gt;1版 をインポートしました&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;2018年6月28日 (木) 19:46時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ja&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(相違点なし)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Yamyam</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Xiaoxiangquan/GoogleSummerOfCode/2011/Internationalization/notes_for_developers&amp;diff=106798&amp;oldid=prev</id>
		<title>wiki&gt;Xiaoxiangquan: /* I18N Approaches */</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Xiaoxiangquan/GoogleSummerOfCode/2011/Internationalization/notes_for_developers&amp;diff=106798&amp;oldid=prev"/>
		<updated>2011-09-06T16:39:34Z</updated>

		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;I18N Approaches&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Notes for Developers=&lt;br /&gt;
First of all, you are strongly recommended to read the [[User:Xiaoxiangquan/GoogleSummerOfCode/2011/Internationalization/design|Implementation Design]] before reading this page, as that page contains important foundations.&lt;br /&gt;
&lt;br /&gt;
=For C Code=&lt;br /&gt;
&lt;br /&gt;
== Foundations ==&lt;br /&gt;
Include the header, which contains _() and N_() Macro:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;BLF_api.h&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the compiler complains that no &amp;quot;BLF_api.h&amp;quot; has been found, please edit the right CMakelists.txt and SConstruct to add the header directory /source/blender/blenfont.&lt;br /&gt;
&lt;br /&gt;
And of course, make sure that you have configured the building system with INTERNATIONAL enabled, and call any i18n functions after BLF_lang_set(&amp;quot;&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
== I18N Approaches ==&lt;br /&gt;
- For simple texts, try to use _(&amp;quot;msgid&amp;quot;) directly. It combines marking and runtime translation together.&lt;br /&gt;
&lt;br /&gt;
- For texts that cannot be stored localizedly, for example, those ID strings which should be kept in English while also needed to be displayed in the UI, just use N_(&amp;quot;msgid&amp;quot;) to mark them, and do the runtime translation at the last moment.&lt;br /&gt;
&lt;br /&gt;
- For texts in some arrays or structs initialization that cannot contain a function call like _(), use N_(&amp;quot;msgid&amp;quot;) to mark them, and run a special gettext initialization somewhere before making use of the arrays or structs.&lt;br /&gt;
&lt;br /&gt;
Note that we have marked the target texts. This is the necessary step to help xgettext to gather them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Special Points for RNA==&lt;br /&gt;
The rna files are linked as makesrna firstly, which will generate rna_*_gen.c. These are the real parts linked into blender. So we needn't do anything in rna_*.c except marking.&lt;br /&gt;
&lt;br /&gt;
Mark strings with N_(). The commonest situations are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/* EnumPropertyItem arrays, mostly show as options */&lt;br /&gt;
static EnumPropertyItem rotation_units[] = {&lt;br /&gt;
  {0, &amp;quot;DEGREES&amp;quot;, 0, N_(&amp;quot;Degrees&amp;quot;), N_(&amp;quot;Use degrees for measuring rotation&amp;quot;)},&lt;br /&gt;
  {USER_UNIT_ROT_RADIANS, &amp;quot;RADIANS&amp;quot;, 0, N_(&amp;quot;Radians&amp;quot;), &amp;quot;&amp;quot;},&lt;br /&gt;
  {0, NULL, 0, NULL, NULL}};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/* Property */&lt;br /&gt;
prop= RNA_def_property(srna, &amp;quot;use_separate&amp;quot;, PROP_BOOLEAN, PROP_NONE);&lt;br /&gt;
RNA_def_property_boolean_sdna(prop, NULL, &amp;quot;flag&amp;quot;, USER_UNIT_OPT_SPLIT);&lt;br /&gt;
RNA_def_property_ui_text(prop, N_(&amp;quot;Separate Units&amp;quot;), N_(&amp;quot;Display units in pairs&amp;quot;));&lt;br /&gt;
RNA_def_property_update(prop, NC_WINDOW, NULL);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After first build, you can check the generated source files and find out which property list the texts belongs to, and add it to the rna_access.c:RNA_types_init_gettext()'s target struct array. Then the collection and translation will take place.&lt;br /&gt;
&lt;br /&gt;
=For Python Code=&lt;br /&gt;
We have supplied blf.gettext(msgid) and blf.fake_gettext(msgid) which do the same things as _() and N_() in C code. Generally, functions can be called in most places in python, so you can just act like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from blf import gettext as _&lt;br /&gt;
...&lt;br /&gt;
label = -(&amp;quot;String&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure rename gettext  as _, and fake_gettext as N_, or the xgettext cannot gather the texts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So far, there is only one special case that we cannot apply _() to a python doc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
class A:&lt;br /&gt;
  '''doc'''&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We'll handle it like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
class A:&lt;br /&gt;
  '''doc'''&lt;br /&gt;
  --doc-- = -('doc')&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All these are true for add-on scripts, too.&lt;br /&gt;
&lt;br /&gt;
=Gather New Text Sources=&lt;br /&gt;
Everytime you have marked the first string in a source file, add it to the /po/POTFILES.in, so that they can be gathered.&lt;br /&gt;
&lt;br /&gt;
Then execute /po/update_pot.py, which will call the system's xgettext command. Checking the /po/blender.pot, you'll find those texts have been collected.&lt;br /&gt;
&lt;br /&gt;
=Add a New Language=&lt;br /&gt;
If you want to add a new language, just add a new empty X.po under the /po, and run update_po.py, then you can edit the initialized X.po.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, make a folder at /release/bin/.blender/locale/X, run update_mo.po to compile the new PO file to a MO.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then, edit the /source/blender/makesrna/intern/rna_userdef.c : rna_def_userdef_system(), add an item in the language_items array. This will be shown in the language selection menu.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
At last, edit the /source/blender/blenfont/intern/blf_lang.c, add an item in the lang_to_locale array. This will set the real language when application starts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- Done! Enjoy it.&lt;/div&gt;</summary>
		<author><name>wiki&gt;Xiaoxiangquan</name></author>
		
	</entry>
</feed>