[Openid-specs-ab] Language Script Tags

Axel.Nennker at telekom.de Axel.Nennker at telekom.de
Thu Mar 14 21:57:22 UTC 2013

e.g.: in plain Javascript 
Save the attached file and open it in a browser. It sorts the tags of the JSON object "j" and marks the current locale client_name in bold.
Could be done in jQuery in a more fancy style but...
Could have a handler (member function of an openid object...) for each known_field


<html><head><meta charset="utf-8"><title>test lang tags</title>
function f() {
  function member(x,arr) {
    for (var i=0; i<arr.length; i++) {
      if (x === arr[i]) return true;
    return false;
  function startWith(x,arr) {
    for (var i=0; i<arr.length; i++) {
      if (x.indexOf(arr[i]) == 0) return true;
    return false;
  var locale = "en-us";
  var j = {
    "client_name#en-us": "Test Client",
    "client_name#ja-Jpan-JP": "ワタシ用の例",
    "logo_url": "https://client.example.org/logo.png"
  var known_fields = ["client_name", "redirect_uris", "logo_url"];
  var lang_fields = ["client_name"];
  try {
    for (var field in j) {
      if (startWith(field,known_fields)) {
        var s = field.split('#');
        if (member(s[0],lang_fields)) {
          if (s.length === 2) {
            if (locale == s[1]) {
              document.getElementById("lang").innerHTML += "<div><b>" + j[field] + "</b></div>";
            } else {
              document.getElementById("lang").innerHTML += "<div>" + j[field] + "</div>";
          } else {
            // default
            document.getElementById("lang").innerHTML += "<div>" + j[field] + "</div>";
        } else {
          document.getElementById("other").innerHTML += "<div>" + j[field] + "</div>";
          // not language specific field like redirect_uris
      } else {
        alert("unknown field " + field);
  } catch (e) {

-----Original Message-----
From: openid-specs-ab-bounces at lists.openid.net [mailto:openid-specs-ab-bounces at lists.openid.net] On Behalf Of Vladimir Dzhuvinov / NimbusDS
Sent: Thursday, March 14, 2013 8:27 PM
To: Justin Richer; openid-specs-ab at lists.openid.net
Subject: Re: [Openid-specs-ab] Language Script Tags

Hi Justin,

You can have a look at the Nimbus LangTag library:


It was created specifically to address our need for constructing and parsing language tags in OIDC. Some of the parsing logic is however found in the SDK, you'll probably have to dig for it in the source code.


Vladimir Dzhuvinov : www.NimbusDS.com : vladimir at nimbusds.com

-------- Original Message --------
Subject: [Openid-specs-ab] Language Script Tags
From: Justin Richer <jricher at mitre.org>
Date: Thu, March 14, 2013 3:10 pm
To: "openid-specs-ab at lists.openid.net"
<openid-specs-ab at lists.openid.net>

In implementing things, I've run into a problem when looking to parse values with the language script tags and I'm wondering what other developers have done.

Specifically, the hash tag (#) is not a valid member name in JavaScript,

Python, PHP, or Java (and likely many others), which means I can't do a simple JSON-to-Object deserialization on any fields that use this construct. In other words, say I've got this JSON:

 { "client_name#en-us": "Test Client" }

Parsing that to JavaScript, I'd expect to be able to use the object accessor, like:


But that's not valid JavaScript. Yes, I can use array accessor notation,

but it's inconsistent with other fields. Similarly in Java, I'd get something like this in a blindly-mapped object:


but that is also not a valid Java method name. It's the same basic story

on just about every language I've poked at in the last few minutes here,

so I can't be the first one to have run into this. What has everyone else done to overcome this limitation in the common parse/map operation?

Do you have custom parsers that map the field names? Do you just not use

object-level accessors for these fields?

 -- Justin
Openid-specs-ab mailing list
Openid-specs-ab at lists.openid.net
Openid-specs-ab mailing list
Openid-specs-ab at lists.openid.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openid.net/pipermail/openid-specs-ab/attachments/20130314/026715cd/attachment.html>

More information about the Openid-specs-ab mailing list