From f048a584088be4f4ee45f0a59f6c66b08898c299 Mon Sep 17 00:00:00 2001 From: louyihua Date: Sun, 25 May 2014 14:27:41 +0800 Subject: [PATCH] i18n: Make values that has 'display_name' be displayed localized in editor Dictionary values like Boolean, or some other value types which has 'display_name' can now be displayed with the localized version. --- common/lib/xmodule/xmodule/x_module.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index f998a9b0d4..c7b905b860 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -756,9 +756,12 @@ class XModuleDescriptor(XModuleMixin, HTMLSnippet, ResourceTemplates, XBlock): Can be limited by extending `non_editable_metadata_fields`. """ def jsonify_value(field, json_choice): - if isinstance(json_choice, dict) and 'value' in json_choice: + if isinstance(json_choice, dict): json_choice = dict(json_choice) # make a copy so below doesn't change the original - json_choice['value'] = field.to_json(json_choice['value']) + if 'display_name' in json_choice: + json_choice['display_name'] = get_text(json_choice['display_name']) + if 'value' in json_choice: + json_choice['value'] = field.to_json(json_choice['value']) else: json_choice = field.to_json(json_choice) return json_choice