Skip to content

Instantly share code, notes, and snippets.

@tobiastom
Forked from jeena/gist:476817
Created July 15, 2010 11:15
Show Gist options
  • Save tobiastom/476825 to your computer and use it in GitHub Desktop.
Save tobiastom/476825 to your computer and use it in GitHub Desktop.
<?php
class Foo {
protected $description_de = 'Beschreibung';
protected $description_en = 'Description';
protected $localizedProperties = array( 'description' );
public function __get( $key ) {
if ( !in_array( $key, $this->localizedProperties ) ) {
throw new Exception( 'Unknown property');
}
return property_exists( $this, $userProperty ) ? $this->$userProperty : $key . '_' . Locale::defaultLocale();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment