Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create New LocalizedModel #71

Open
lonnieezell opened this issue Mar 27, 2015 · 0 comments
Open

Create New LocalizedModel #71

lonnieezell opened this issue Mar 27, 2015 · 0 comments

Comments

@lonnieezell
Copy link
Member

In order to support more localized strings for any user-generated content, we need to provide a new model that will make that easy and painless for them. This should allow language blocks to be stored for an language (or idiom as the user guide calls it) for any table/type of info. The simplest way to handle this is probably through a single table with the following fields:

  • object_id
  • table
  • field
  • language
  • text

So we would be creating a new model:

  • extends from CIDbModel, called LocalizedModel
  • new class var: $localized_fields which is an array of column names that will have localization.
  • new class_var: $default_language which will default to english but can be overridden by child classes to provide new default.
  • new method: with_lang() that sets the language for that call. Uses a $temp_language class var
  • new method: with_all_langs() that tells the system to retrieve all text strings for the returned object.
  • new after_find observer that examines the select statement in the class and adds the appropriate left joins to pull in the language strings. If only one language is returned it should simply include the language string in that object's field. If multiple languages are being returned, should make that field an array of key/value pairs where the key is the language and the value is the text string.
  • new before_update observer that will remove any localized fields that need to be saved out to the language database.
  • new after_update observer that will actually our update strings based on the current langauge.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant