From 1f13ef66c078cde880b7a3b8ba044a9ffe10f051 Mon Sep 17 00:00:00 2001 From: Alex King Date: Sat, 10 Apr 2004 05:22:49 +0000 Subject: [PATCH] first pass at the localization class git-svn-id: https://develop.svn.wordpress.org/trunk@1057 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/class-language.php | 57 ++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 wp-includes/class-language.php diff --git a/wp-includes/class-language.php b/wp-includes/class-language.php new file mode 100644 index 0000000000..d72051e87b --- /dev/null +++ b/wp-includes/class-language.php @@ -0,0 +1,57 @@ +author = $author; + $this->author_url = $author_url; + $this->charset = $charset; + $this->name = $name; + $this->strings = $strings; + } + + function str($key, $vars = '') { + if (!isset($this->strings[$key])) { // not using array_key_exists() because it is slower + return false; + } + if (empty($vars)) { + print($this->strings[$key]); + return true; + } + else { + if (strstr($vars, ',')) { + $vars = explode(',', $vars); + } + else { + $vars = array($vars); + } + $string = $this->strings[$key]; + for ($i = 0; $i < count($vars); $i++) { + $string = @str_replace("__".$i, $vars[$i], $string); + if (!$string) { + print('

Error, could not replace __'.$i + .' with '.$vars[$i].' in string '.$key.'.

' + ); + } + } + print($string); + return true; + } + } +} + +?> \ No newline at end of file