Title: [1288] trunk/core/distribution/src/site/content: Updated i18n documentation.
Revision
1288
Author
mauro
Date
2009-10-04 07:50:28 -0500 (Sun, 04 Oct 2009)

Log Message

Updated i18n documentation.

Modified Paths


Added Paths

Removed Paths

Diff

Copied: trunk/core/distribution/src/site/content/i18n-scenarios.html (from rev 1278, trunk/core/distribution/src/site/content/i18n.html) (0 => 1288)

--- trunk/core/distribution/src/site/content/i18n-scenarios.html	                        (rev 0)
+++ trunk/core/distribution/src/site/content/i18n-scenarios.html	2009-10-04 12:50:28 UTC (rev 1288)
@@ -0,0 +1,129 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+<title>Non-English Scenarios</title>
+</head>
+
+<body>
+
+<h2>Writing Scenarios in your language</h2>
+
+<p>Good and effective communication is key to BDD. Therefore,
+writing scenarios in the <a href=""
+spoken by the business users is essential. And even though the patterns
+used to match the scenario steps to Java methods can be written in any
+language, the <a
+    href=""
+still need to be expressed in different languages.</p>
+
+<p>JBehave by default supports English as the scenario language. By
+supporting the internationalisation (i18n) of keywords by Java <a
+    href=""
+it also allows the scenarios to be written in any language. All is
+needed to configure the use of <a
+    href=""
+for a given Locale. Each locale has a separate keywords properties file.
+E.g. for Italian locale, the file <b>keywords_it.properties</b> is:</p>
+<pre class="brush: bdd">
+Scenario=Scenario:
+GivenScenarios=Dati gli scenari:
+ExamplesTable=Esempi:
+ExamplesTableRow=Esempio:
+Given=Dato che
+When=Quando
+Then=Allora
+And=E
+Pending=PENDENTE
+NotPerformed=NON ESEGUITO
+Failed=FALLITO
+</pre>
+<p>We need to configure the use of the i18n-ed keywords in the <a
+    href=""
+e.g.:</p>
+<pre class="brush: java">
+public class ItTraderScenario extends JUnitScenario {
+
+	public ItTraderScenario(final ClassLoader classLoader) {
+		super(new PropertyBasedConfiguration() {
+			@Override
+			public ScenarioDefiner forDefiningScenarios() {
+				// use underscored camel case scenario files with extension ".scenario"
+				return new ClasspathScenarioDefiner(
+						new UnderscoredCamelCaseResolver(".scenario"),
+						new PatternScenarioParser(this), classLoader);
+			}
+
+			@Override
+			public ScenarioReporter forReportingScenarios() {
+				// report outcome in Italian (to System.out)
+				return new PrintStreamScenarioReporter(keywordsFor(new Locale("it"), classLoader));
+			}
+
+			@Override
+			public KeyWords keywords() {
+				// use Italian for keywords
+				return keywordsFor(new Locale("it"), classLoader);
+			}
+
+		}, new ItTraderSteps(classLoader));
+	}
+
+	protected static KeyWords keywordsFor(Locale locale, ClassLoader classLoader) {
+		return new I18nKeyWords(locale, new StringEncoder(), "org/jbehave/examples/trader/i18n/keywords", classLoader);
+	}
+
+}
+</pre>
+<p>The corresponding i18n-ed <a
+    href=""
+also requires the configuration of i18n-ed keywords:</p>
+
+<pre class="brush: java">
+public class ItTraderSteps extends Steps {
+
+    private Stock stock;
+
+    public ItTraderSteps(ClassLoader classLoader) {
+    	// Use Italian for keywords
+        super(new StepsConfiguration(keywordsFor(new Locale("it"), classLoader)));
+    }
+
+    @Given("ho un'azione con simbolo $symbol e una soglia di $threshold")
+    public void aStock(@Named("symbol") String symbol, @Named("threshold") double threshold) {
+        stock = new Stock(symbol, threshold);
+    }
+
+    @When("l'azione e' scambiata al prezzo di $price")
+    public void stockIsTraded(@Named("price") double price) {
+        stock.tradeAt(price);
+    }
+
+    @Then("lo status di allerta e' $status")
+    public void alertStatusIs(@Named("status") String status) {
+        ensureThat(stock.getStatus().name(), equalTo(status));
+    }
+
+	protected static KeyWords keywordsFor(Locale locale, ClassLoader classLoader) {
+		return new I18nKeyWords(locale, new StringEncoder(), "org/jbehave/examples/trader/i18n/keywords", classLoader);
+	}
+
+}
+</pre>
+<p>Note that the i18n-ed keywords not only allow the translation of
+the keywords used in parsing the textual scenario, but also the keywords
+used in the reporting of the scenario execution, e.g. <b>Pending</b>, <b>NotPerformed</b>
+and <b>Failed</b>.</p>
+
+<h2>Why are different languages not supported out-of-the-box?</h2>
+
+<p>Most non-English languages require characters that are rendered
+inconsistently using the native encoding of a given operating system. We
+are working on a consistent solution that is re-usable across multiple
+platforms.</p>
+
+<div class="clear">
+<hr />
+</div>
+
+</body>
+</html>

Deleted: trunk/core/distribution/src/site/content/i18n.html (1287 => 1288)

--- trunk/core/distribution/src/site/content/i18n.html	2009-10-04 12:37:43 UTC (rev 1287)
+++ trunk/core/distribution/src/site/content/i18n.html	2009-10-04 12:50:28 UTC (rev 1288)
@@ -1,126 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
-<head>
-<title>Using your language</title>
-</head>
-
-<body>
-
-<h2>Writing Scenarios in your Language</h2>
-
-<p>Good and effective communication is key to BDD. Therefore,
-writing scenarios in the <a href=""
-spoken by the business users is essential. And even though the patterns
-used to match the scenario steps to Java methods can be written in any
-language, the <a
-    href=""
-still need to be expressed in different languages.</p>
-
-<p>JBehave allows the internationalisation (I18N) of keywords by by
-Java <a
-    href=""
-thus allowing the scenarios to be written in any language. All is needed
-to configure the use of <a
-    href=""
-for a given Locale. Each locale has a separate keywords properties file.
-E.g. for Italian locale, the file <b>keywords_it.properties</b> is:
-<pre class="brush: bdd">
-Scenario=Scenario:
-GivenScenarios=Dati gli scenari:
-ExamplesTable=Esempi:
-ExamplesTableRow=Esempio:
-Given=Dato che
-When=Quando
-Then=Allora
-And=E
-Pending=PENDENTE
-NotPerformed=NON ESEGUITO
-Failed=FALLITO
-</pre>
-</p>
-<p>We need to configure the use of the I18N-ed keywords in the <a
-    href=""
-e.g.:
-<pre class="brush: java">
-public class ItTraderScenario extends JUnitScenario {
-
-	public ItTraderScenario() {
-		this(Thread.currentThread().getContextClassLoader());
-	}
-
-	public ItTraderScenario(final ClassLoader classLoader) {
-		super(new PropertyBasedConfiguration() {
-			@Override
-			public KeyWords keywords() {
-				// use Italian for keywords
-				return new I18nKeyWords(new Locale("it"));
-			}
-
-		}, new ItTraderSteps(classLoader));
-	}
-
-}
-</pre>
-</p>
-<p>The corresponding I18N-ed <a
-    href=""
-also requires the configuration of I18N-ed keywords:
-<pre class="brush: java">
-public class ItTraderSteps extends Steps {
-
-    private Stock stock;
-
-    public ItTraderSteps(ClassLoader classLoader) {
-    	// Use Italian for keywords
-        super(new StepsConfiguration(new I18nKeyWords(new Locale("it"))));
-    }
-
-    @Given("ho un'azione con simbolo $symbol e una soglia di $threshold")
-    public void aStock(@Named("symbol") String symbol, @Named("threshold") double threshold) {
-        stock = new Stock(symbol, threshold);
-    }
-
-    @When("l'azione e' scambiata al prezzo di $price")
-    public void stockIsTraded(@Named("price") double price) {
-        stock.tradeAt(price);
-    }
-
-    @Then("lo status di allerta e' $status")
-    public void alertStatusIs(@Named("status") String status) {
-        ensureThat(stock.getStatus().name(), equalTo(status));
-    }
-
-}
-</pre>
-</p>
-<p>Note that the I18N-ed keywords not only allow the translation of
-the keywords used in parsing the textual scenario, but also the keywords
-used in the reporting of the scenario execution, e.g. <b>Pending</b>, <b>NotPerformed</b>
-and <b>Failed</b>.</p>
-
-<h2>What if your language is not currently supported?</h2>
-
-<p>You can configure your own bundle,
-<pre class="brush: java">    
-    String yourBundleName = "path/to/your/keywords"
-    Locale yourLocale = new Locale(...); 
-
-    KeyWords keywords = new KeyWords(yourBundleName, yourLocale);
-</pre>
-Just be sure that you use on the existing bundles as a template to
-ensure all the keywords are present.
-</p>
-<p>Note that by the route you can also override the keywords for a
-locale already supported.</p>
-<p>If you do find yourself providing keywords for a new language, we
-are happy to support it out of the box. Simply get in touch via the <a
-    href="" lists</a> or attach the bundle for
-the new locale to an enhancement request via our <a
-    href="" tracking</a>.</p>
-
-<div class="clear">
-<hr />
-</div>
-
-</body>
-</html>

Modified: trunk/core/distribution/src/site/content/sitemap.xml (1287 => 1288)

--- trunk/core/distribution/src/site/content/sitemap.xml	2009-10-04 12:37:43 UTC (rev 1287)
+++ trunk/core/distribution/src/site/content/sitemap.xml	2009-10-04 12:50:28 UTC (rev 1288)
@@ -21,7 +21,7 @@
     <page>developing-scenarios.html</page>
     <page>configuring-scenarios.html</page>
     <page>running-scenarios.html</page>
-    <page>i18n.html</page>
+    <page>i18n-scenarios.html</page>
   </section>
   <section>
     <name>Advanced Topics</name>


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to