Skip to content

Instantly share code, notes, and snippets.

@karmi
Created August 13, 2008 09:14
Show Gist options
  • Save karmi/5219 to your computer and use it in GitHub Desktop.
Save karmi/5219 to your computer and use it in GitHub Desktop.
# Dump of table translations
# ------------------------------------------------------------
CREATE TABLE `translations` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) collate utf8_czech_ci default NULL,
`description` text collate utf8_czech_ci,
`lang` varchar(255) collate utf8_czech_ci default NULL,
`reference_id` int(11) default NULL,
`created_at` datetime default NULL,
`updated_at` datetime default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `lang_index` (`lang`,`reference_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
# Rails console session:
# ------------------------------------------------------------
>> p = Product.find :first
Product Load (0.000348) SELECT * FROM `products` LIMIT 1
=> #<Product id: 1, name: "Skoda Octavia", description: "The Škoda Octavia is a small family car produced b...", manufactured_on: "2008-08-12 22:35:00", created_at: "2008-08-12 22:42:22", updated_at: "2008-08-12 23:40:35", category_id: nil>
>> I18n.locale
=> "en-US"
>> p.name
=> "Skoda Octavia"
>> p.description
=> "The Škoda Octavia is a small family car produced by Czech automaker Škoda Auto since 1996, its name revived from a model originally produced between 1959 and 1971. The current Octavia is available in five-door liftback and estate body styles. A common misconception is that the Octavia is a saloon due to its long boot."
>> I18n.locale = 'cs'
=> "cs"
>> p.name
Translation Load (0.000662) SELECT * FROM `translations` WHERE (`translations`.`lang` = 'cs') AND (`translations`.reference_id = 1) LIMIT 1
=> "Škoda Octavia"
>> p.description
Translation Load (0.000426) SELECT * FROM `translations` WHERE (`translations`.`lang` = 'cs') AND (`translations`.reference_id = 1) LIMIT 1
=> "?koda Octavia je model automobilu vyráb?ný ?eskou automobilkou ?koda od roku 1996. V roce 1999 sv?tlo sv?ta spat?il model, který má náhon na v?echny ?ty?i kola. P?i?azení zadní nápravy obstarává spojka Haldex, která se uvádí v ?innost p?i prokluzu p?ední nápravy. V modelovém roce 2001 pro?la Octavia faceliftem. Také byl uveden model RS, který m?l výkon 132 kW (180 koní). Od roku 2004 je první generace prodávána pod názvem Octavia Tour. Je vyráb?na sou?asn? s druhou generací Octavia II."
>> p.localized_description 'de'
Translation Load (0.000424) SELECT * FROM `translations` WHERE (`translations`.`lang` = 'de') AND (`translations`.reference_id = 1) LIMIT 1
=> "Missing"
>> p.set_localized_description :de => 'Der Skoda Octavia ist seit 1996 das erste Modell von Skoda, das komplett unter der Fuehrung von Volkswagen erstellt wurde.'
Translation Load (0.000426) SELECT * FROM `translations` WHERE (`translations`.`lang` = 'de') AND (`translations`.reference_id = 1) LIMIT 1
SQL (0.000079) BEGIN
Translation Update (0.000357) UPDATE `translations` SET `description` = 'Der Skoda Octavia ist seit 1996 das erste Modell von Skoda, das komplett unter der Fuehrung von Volkswagen erstellt wurde.', `updated_at` = '2008-08-13 09:12:44' WHERE `id` = 2
SQL (0.001502) COMMIT
=> true
>> p.localized_description 'de'
Translation Load (0.000502) SELECT * FROM `translations` WHERE (`translations`.`lang` = 'de') AND (`translations`.reference_id = 1) LIMIT 1
=> "Der Skoda Octavia ist seit 1996 das erste Modell von Skoda, das komplett unter der Fuehrung von Volkswagen erstellt wurde."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment