From: Rafael C. <raf...@gm...> - 2014-12-18 03:52:33
|
Hi, * About existing table: If no additional comments on this topic, I will do the sql file to modify `stockdescriptiontranslations`. * Info in rows: My proposal is to merge ALL item descriptions in ONE table (all short description -item title- and all long description -item narrative-; all languages including system default language). The fields stockmaster.description and stockmaster.longdescription became obsolete (to be dropped in the future). Short and Long descriptions of a specific language are on the same record. This simplifies the query code. In this case: 1. If no short_description and no long_description translation for an item, it is unneeded to have this record. 2. If short_description and/or long_description translation are null (empty), we can do or not an additional query to get the missing description in the default language. That is that I called "Fall back to system language" in previous message. Parameters: $stockid = '2000000300047';// As example. Defined elsewhere... $Language = 'en_US.utf8';// As example. Defined elsewhere... $DefaultLanguage = 'es_ES.utf8';// As example. Defined elsewhere... My code is: $ShortDescription = _('Not available');// In case of no description. $LongDescription = _('Not available');// In case of no description. $Query="SELECT * FROM stockdescription WHERE stockid='" . $stockid ."' AND language='" . $Language . "'"; $Result=mysqli_query($Connection, $Query); $Row=mysqli_fetch_array($Result); if(!empty($Row['short'])) {// If not empty, sets the description in the selected language. $ShortDescription = htmlspecialchars($Row['short']); // BEGIN: Fall back to the default language. } else { $Query="SELECT * FROM stockdescription WHERE stockid='" . $stockid ."' AND language='" . $DefaultLanguage . "'"; $Result=mysqli_query($Connection, $Query); $Row=mysqli_fetch_array($Result); if(!empty($Row['short'])) {// If not empty, sets the description in the default language. $ShortDescription = htmlspecialchars($Row['short']); } // END: Fall back to the default language. } if(!empty($Row['long'])) {// If not empty, sets the description in the selected language. $LongDescription = nl2br(htmlspecialchars($Row['long'])); // BEGIN: Fall back to the default language. } else { $Query="SELECT * FROM stockdescription WHERE stockid='" . $stockid ."' AND language='" . $DefaultLanguage . "'"; $Result=mysqli_query($Connection, $Query); $Row=mysqli_fetch_array($Result); if(!empty($Row['long'])) {// If not empty, sets the description in the default language. $LongDescription = nl2br(htmlspecialchars($Row['long'])); } // END: Fall back to the default language. } Instead of the "fall back code", it could be also the Google Translate API. Also, it can be deleted the fall back code (between comments "BEGIN" and "END"). Note: I enclose a PrintScreen of my stockdescriptiontranslations table. It is only plain text, no arrays. Best regards, Rafael. 2014-12-17 18:35 GMT-06:00 Pak Ricard <pak...@gm...>: > > Hi: > > I think we are OK with existing table and adding some fields will be OK, > but there are some issues I would like to point out, > > Why, on items without traslation, do we keep a row in that table? Why do > we have rows without any useful information? I think it makes SQL queries > more complicated, and I can't see the advantage of this. Please check > capture01 attached file from phpMyAdmin. For all items without translation, > there's a row with stockid, and "Array" as language_id, and no > descriptiontranslation. No clue why. Is it a bug or serves some needs I > can't see? > > I agree with Phil that the long description addition should be a "copy - > paste" of the short description one. At first glance should not be > difficult. That's why I supposed it was already coded or not coded for some > reason. > > I think we should add a field called revisionneeded set to TRUE when > description or long description have been modified or FALSE otherwise. > Then, some script to list the items needing revision of translation. > Usually the person translating is not the same as the person in charge of > maintaining the item info in original language. > > I am working with automatic translation API from Google > https://console.developers.google.com. It's a Google paid service, and I > think it's worth it (20 USD for 1.000.000 characters translated), as it > does the rough job and humans only need to revise and correct here and > there. > > First tests have been succesful, so once we have this table stockdescriptiontranslations > up and running OK I will commit some scripts, mainly: > script automatically translating the descriptions without translation or > recently modified. > script to show automatic translations needing human supervision (probably > the same or a mod of the script mentioned in previous paragraph) > > Specially to Rafael: I add / modify fields quite often, and never had an > issue, except when I shortened a text field :-( . Do a table backup just > before start messing around, just in case. > > Hope it helps and we all find a clear way to move forward on this. > > > Regards, > Ricard > > 2014-12-18 6:47 GMT+08:00 Rafael Chacón <raf...@gm...>: >> >> Hi, >> >> My arguments: >> >> * About tables: IMHO (but I am not a PHP programmer), >> >> CREATE TABLE IF NOT EXISTS `stockdescriptiontranslations` ( >> `stockid` varchar(20) NOT NULL DEFAULT '', >> `language_id` varchar(10) NOT NULL DEFAULT 'en_GB.utf8', >> `descriptiontranslation` varchar(50) NOT NULL, >> PRIMARY KEY (`stockid`,`language_id`) >> ) ENGINE=InnoDB DEFAULT CHARSET=utf8; >> >> and >> >> CREATE TABLE IF NOT EXISTS `stockdescription` ( >> `stockid` varchar(20) NOT NULL DEFAULT '' COMMENT 'Item code', >> `language` varchar(10) NOT NULL DEFAULT '' COMMENT 'Item language code', >> `short` varchar(50) DEFAULT NULL COMMENT 'Item short description', >> `long` text COMMENT 'Item long description', >> PRIMARY KEY (`stockid`,`language`) >> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Item descriptions'; >> >> look very similar. I suppose it will be easy to "update" the first table: >> add new fields, modify others (I have the code to create the second table, >> but not to update de first table). >> >> * About "hot plug-in": I am not sure if that is a common need, but I am >> worry that if we modify fields instead of adding fields --if there is any >> error or oversight-- we could affect the company operation. My suggestion >> is to add fields of the second table inside de first table (if use old >> table). >> >> * About compatibility with CARTwebERP: Months before Mo.Kelly dead, we >> were working on this. I do not know how widespread is this. I saw the code >> in Joomla! Extensions Directory (http://extensions.joomla.org). It has >> my translation to Spanish and to French, but I can not see anything related >> with additional tables. >> >> * About speed and readability of the code: I prefer the argument of >> someone who knows better this topic. >> >> Best regards, Rafael. >> >> >> 2014-12-17 15:39 GMT-06:00 <ph...@lo...>: >> >>> I wasn't thinking it would be that difficult... we don't need a new >>> table do we? >>> Why can't we use the existing table and just add a field for the >>> translated long description ... applying similar logic for the >>> translation was we do for the short description? >>> >>> Phil >>> >>> On 2014-12-17 13:58, Rafael Chacón wrote: >>> > Hi Ricard, >>> > >>> > I will be glad to commit changes for short and long description >>> > translation. but I need help from PHP programmers. I explain myself: >>> > >>> > * We use a new table (not an exist table): >>> > CREATE TABLE IF NOT EXISTS `stockdescription` ( >>> > `stockid` varchar(20) NOT NULL DEFAULT '' COMMENT 'Item code', >>> > `language` varchar(10) NOT NULL DEFAULT '' COMMENT 'Item language >>> > code', >>> > `short` varchar(50) DEFAULT NULL COMMENT 'Item short description', >>> > `long` text COMMENT 'Item long description', >>> > PRIMARY KEY (`stockid`,`language`) >>> > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Item descriptions'; >>> > >>> > This is for: (1) "Hot add" to a working copy of webERP and "secure >>> > backup" of old operation; (2) compatibility with a Joomla extension >>> > e-Cart;"Minor" speed and readability (?). >>> > >>> > --> To commit changes, Do we use a new table or modify an existing >>> > one? >>> > >>> > * We have to modify several scripts (e.g. Stocks.php, >>> > PrintCustTrans.php, PrintCustTransportrait.php, etc.). When there is >>> > no description in the selected language, he have two code branches: >>> > >>> > (1) "Fall back" to system language (defined in ~/config.php, >>> > $DefaultLanguage = 'xx_XX.utf8';). If is null or empty, _('Not >>> > available'). Useful when we forgot to setup a translation; but >>> > customer sees a description in other language. >>> > >>> > (2) Directly sets to _('Not available'). A little bit faster, but no >>> > information is shown to the customer (only "not available"). >>> > >>> > --> To commit changes, Do we use code with or without the "fall back" >>> > to system language? >>> > >>> > * Input window for long description translation. >>> > It is recommended to have "side-by-side" long description >>> > translations, but in this case it is a big and uncomfortable window. >>> > >>> > --> Ideas? Suggestions? >>> > >>> > Best regards, Rafael. >>> > >>> > Hi Rafael: >>> > >>> > i'm also needing the short and long description to use on the shop >>> > online. It would be great if you could commit (or send via email) the >>> > work done to maintain the translations of long descriptions in webERP. >>> > I could help finish it :-) >>> > >>> > Regards, >>> > Ricard >>> > >>> > 2014-12-17 14:00 GMT+08:00 Rafael Chacón >>> > <raf...@gm...>: >>> > >>> >> Hi, >>> >> >>> >> I am working with stockdescription table for translation of short >>> >> and long description to use in a e-cart. It is not fully tested and >>> >> the main problem is the usability (easy to maintain the >>> >> translations). >>> >> Also, the field unit of mesure needs translation, except for unit >>> >> of mesure symbols (m, m2, L, kg, ...). >>> >> >>> >> Best regards, Rafael. >>> >> El 16/12/2014 23:02, "Phil Daintree" <ph...@lo...> >>> >> escribió: >>> >> >>> >> I have not coded that, but no reason why we couldn't add a text >>> >> field to stockdescriptiontranslations for longdescriptiontranslation >>> >> and add in a field to the stock form to allow the field to be >>> >> translated to the maintained language(s) >>> >> >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server >>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards >>> with Interactivity, Sharing, Native Excel Exports, App Integration & more >>> Get technology previously reserved for billion-dollar corporations, FREE >>> >>> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk >>> _______________________________________________ >>> Web-erp-developers mailing list >>> Web...@li... >>> https://lists.sourceforge.net/lists/listinfo/web-erp-developers >>> >> >> >> ------------------------------------------------------------------------------ >> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server >> from Actuate! Instantly Supercharge Your Business Reports and Dashboards >> with Interactivity, Sharing, Native Excel Exports, App Integration & more >> Get technology previously reserved for billion-dollar corporations, FREE >> >> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk >> _______________________________________________ >> Web-erp-developers mailing list >> Web...@li... >> https://lists.sourceforge.net/lists/listinfo/web-erp-developers >> >> > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > > http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk > _______________________________________________ > Web-erp-developers mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/web-erp-developers > > |