File: localize.html

package info (click to toggle)
jswat2 2.37-1
  • links: PTS
  • area: contrib
  • in suites: etch, etch-m68k
  • size: 7,092 kB
  • ctags: 5,592
  • sloc: java: 43,576; xml: 1,086; sh: 66; makefile: 57
file content (93 lines) | stat: -rw-r--r-- 3,901 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta name="generator"
    content="HTML Tidy for Linux/x86 (vers 1st February 2002), see www.w3.org" />

    <title>JSwat - How to Localize</title>
  </head>

  <body bgcolor="#ffffff">
    <h2>How to Localize</h2>

    <h3>Localizing to Other Locales</h3>

    <p>Localizing JSwat to other locales should be quite simple. Nearly
    all of the user-readable strings in JSwat are stored in files
    called <code>Bundle.properties</code> in the various directories.
    These files define the strings for the default language, English.
    Strings for other locales must be defined in separate files, using
    a file naming convention as described in the documentation for the
    <code>java.util.ResourceBundle</code> class. That information is
    reprinted here for convenience.</p>

    <blockquote>
      <p>Resource bundles belong to families whose members share a
      common base name, but whose names also have additional components
      that identify their locales. For example, the base name of a
      family of resource bundles might be &quot;MyResources&quot;. The
      family should have a default resource bundle which simply has the
      same name as its family - &quot;MyResources&quot; - and will be
      used as the bundle of last resort if a specific locale is not
      supported. The family can then provide as many locale-specific
      members as needed, for example a German one named
      &quot;MyResources_de&quot;.</p>

      <p>Each resource bundle in a family contains the same items, but
      the items have been translated for the locale represented by that
      resource bundle. For example, both &quot;MyResources&quot; and
      &quot;MyResources_de&quot; may have a String that&#39;s used on a
      button for canceling operations. In &quot;MyResources&quot; the
      String may contain &quot;Cancel&quot; and in
      &quot;MyResources_de&quot; it may contain
      &quot;Abbrechen&quot;.</p>

      <p>If there are different resources for different countries, you
      can make specializations: for example,
      &quot;MyResources_de_CH&quot; contains objects for the German
      language (de) in Switzerland (CH). If you want to only modify
      some of the resources in the specialization, you can do so.</p>
    </blockquote>

    <p>The steps for localizing JSwat to another locale should be
    rather straightforward. Start by copying each
    <code>Bundle.properties</code> file to a new name, as described
    above, and modifying the strings after the equals sign (=) on each
    of the lines in the file. There are some lines that need not be
    modified, they are pretty obvious when you see them. These include
    the lines that define the menu structure and toolbar button
    ordering.</p>

    <p>After you have created new <code>Bundle.properties</code> files,
    you may launch JSwat on a platform implementing the desired locale.
    The Java VM should detect the native locale and display the
    appropriate user-visible strings. See <a href="compile.html">this
    page</a> for instructions on compiling and running JSwat.</p>

    <h4>File Format</h4>

    <p>If you are not familiar with Java resource bundles, the file
    format goes something like this:</p>
<pre>
#
# Comment lines start with a &#39;#&#39;
#
key1 = value1

key2 = value2 \
on multiple \
lines.

key3 = value3 \n with \t character escapes.
</pre>

    <p>As you can see, the strings are referenced by a name (e.g.
    &quot;key1&quot;, &quot;key2&quot;), followed an equals sign (=)
    and the localizable string. The string may contain slash-escapes.
    When a line ends with a slash, it means the next line is also a
    part of the value.</p>
  </body>
</html>