File: wzjsonlocalizedstring.py

package info (click to toggle)
warzone2100 4.6.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 660,320 kB
  • sloc: cpp: 676,209; ansic: 391,201; javascript: 78,238; python: 16,632; php: 4,294; sh: 4,094; makefile: 2,629; lisp: 1,492; cs: 489; xml: 404; perl: 224; ruby: 156; java: 89
file content (13 lines) | stat: -rw-r--r-- 471 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/env python3
# encoding: utf-8

# Gets the base language ("en") value from a WZ Json Localized String
def wz_localized_string_get_base_string(value):
	if isinstance(value, dict):
		if 'en' in value:
			return value['en']
		else:
			raise ValueError('Invalid WZ Json localized string - is an object, but has no base "en" key')
	else:
		# non-objects are treated as a single string value that is always expected to be the base ("en") language
		return str(value)