Skip to content

Commit e54949f

Browse files
committed
Added spec text to support language maps. Closes issue #133.
1 parent 920c15e commit e54949f

File tree

1 file changed

+51
-6
lines changed

1 file changed

+51
-6
lines changed

spec/latest/json-ld-syntax/index.html

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ <h2>String Internationalization</h2>
11841184
<h2>JSON-LD Syntax</h2>
11851185

11861186
<p>A JSON-LD document is first, and foremost, a JSON document
1187-
(as defined in [[!RFC5988]]), and any syntactically correct JSON document
1187+
(as defined in [[!RFC4627]]), and any syntactically correct JSON document
11881188
MUST be processed by a conforming JSON-LD processor. However, JSON-LD
11891189
describes a specific syntax to use for expressing Linked Data. This
11901190
includes the use of specific keywords, as identified in <a
@@ -1400,7 +1400,7 @@ <h2>Language Values</h2>
14001400
<tdef>language value</tdef>, is indicated by associating a value with
14011401
an <tref>string</tref> having the lexical from defined in [[!BCP47]]
14021402
which indicates the value's language. Language values may be
1403-
expressed in JSON-LD in three ways:
1403+
expressed in JSON-LD in four ways:
14041404
</p>
14051405

14061406
<ol>
@@ -1409,6 +1409,10 @@ <h2>Language Values</h2>
14091409
<li>By utilizing the <code>@language</code> <tref>keyword</tref> when defining
14101410
a <tref>term</tref> within a <code>@context</code> section.</li>
14111411
<li>By utilizing the expanded form for specifying objects.</li>
1412+
<li>By utilizing the <code>@container</code> <tref>keyword</tref> with a
1413+
value of <code>@language</code> when defining a <tref>term</tref> within
1414+
a <code>@context</code> section. This usage pattern is called a
1415+
<tdef>language map</tdef>.</li>
14121416
</ol>
14131417

14141418
<p>The first example uses the <code>@language</code> keyword to associate a
@@ -1452,9 +1456,9 @@ <h2>Language Values</h2>
14521456
}
14531457
},
14541458
...
1455-
"modified":
1459+
"title":
14561460
****{
1457-
"@value": "JSON-LD",
1461+
"@value": "JSON-LD Syntax",
14581462
"@language": "en"
14591463
}****
14601464
...
@@ -1463,7 +1467,45 @@ <h2>Language Values</h2>
14631467
</pre>
14641468

14651469
<p>Both examples above would generate an object with the value of
1466-
<code>JSON-LD</code> and the language of "English".</p>
1470+
<code>JSON-LD Syntax</code> and the language of <code>en</code>, which is the
1471+
[[!BCP47]] code for the English language.</p>
1472+
1473+
<p>Systems that support multiple languages often need to express data values in
1474+
each language. Typically, such systems also try to ensure that developers have
1475+
a programatically easy way to navigate the datastructures for the
1476+
language-specific data. In this case, <tref>language map</tref>s
1477+
may be utilized.</p>
1478+
1479+
<pre class="example" data-transform="updateExample"
1480+
title="Language map expressing a property in three languages">
1481+
<!--
1482+
{
1483+
"@context":
1484+
{
1485+
"title":
1486+
{
1487+
"@id": "http://purl.org/dc/terms/title"
1488+
"@container": "@language"
1489+
}
1490+
},
1491+
...
1492+
"title":
1493+
****{
1494+
"en": "JSON-LD Syntax",
1495+
"ru": "JSON-LD Синтаксис",
1496+
"ja": "JSON-LDの構文"
1497+
}****
1498+
...
1499+
}
1500+
-->
1501+
</pre>
1502+
1503+
<p>In the example above, the title is expressed in three languages; English,
1504+
Russian, and Japanese. To access the data above in a programming language
1505+
supporting dot-notation accessors for object properties, a developer may use the
1506+
<strong>PROPERTY</strong>.<strong>LANGUAGE</strong> pattern. For example, to
1507+
access the Japanese version of the title, a developer would use the following
1508+
code snippet: <code>obj.title.ja</code>.</p>
14671509

14681510
</section>
14691511

@@ -2784,7 +2826,10 @@ <h2>Context Definition</h2>
27842826
<p>If the <tref>expanded term definition</tref> contains the <code>@language</code> <tref>keyword</tref>,
27852827
the value MUST have the lexical form described in [[!BCP47]] or be <tref>null</tref>.</p>
27862828
<p>If the <tref>expanded term definition</tref> contains the <code>@container</code> <tref>keyword</tref>,
2787-
the value MUST be either <code>@list</code>, <code>@set</code> or be <tref>null</tref>.</p>
2829+
the value MUST be either <code>@list</code>, <code>@set</code>, <code>@language</code>, or be <tref>null</tref>.
2830+
If the value is <code>@language</code>, when the <tref>term</tref> is used outside of the <code>@context</code>, the
2831+
associated value MUST be a <tref>JSON object</tref> whose keys are <tref>string</tref>s that are [[BCP47]] language identifiers.
2832+
The values associated with each [[BCP47]] language string MUST be a <tref>string</tref> or an <tref>array</tref> of <tref>string</tref>s.</p>
27882833
<p>See <a href="#the-context"></a> and <a href="#expanded-term-definition"></a>
27892834
for a further discussion of contexts.</p>
27902835
</section>

0 commit comments

Comments
 (0)