Please help us to make AbanteCart Ideal Open Source Ecommerce Solution for everyone.

Support AbanteCart eCommerce

Author Topic: How to create a language extension?  (Read 14369 times)

Offline Onima

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
How to create a language extension?
« on: November 08, 2014, 08:20:04 PM »
Hi! I'm an absolute newb. I need Abantecart in two languages.

When I select 'Insert Language' there is a note saying that "We recommend creating language as an extension". So how do I get started creating a language extension? I tried googling but didn't find an answer.

yonghan

  • Guest
Re: How to create a language extension?
« Reply #1 on: November 08, 2014, 09:01:18 PM »
Hello,you can look the developer guide on howto create an extension.

http://www.abantecart.com/document_wiki/index.php/AbanteCart_Extension%E2%80%99s_Developer_Guide

The developer tools to help you create the extension skeleton. https://github.com/abantecart/developer_tools_extension

or

you can download free language extension from abantecart marketplace and learn the structure.After you understand,you can copy,rename and edit it as your desired language.

Hope it helps.

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: How to create a language extension?
« Reply #2 on: November 10, 2014, 10:21:16 AM »
Thank you handoyo.
Onima, Additionally, you can search this forum. We had a number of posts related to this topic
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

Offline Onima

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: How to create a language extension?
« Reply #3 on: November 25, 2014, 10:55:01 PM »
Thank you!

So I'm overriding the Spanish language file. Now I'm wondering how to deal with the default_spannish/admin folder. I don't need the admin side translated. Can I just delete the admin folder?

yonghan

  • Guest
Re: How to create a language extension?
« Reply #4 on: November 26, 2014, 12:06:02 AM »
A.F.A.I.K you can delete the admin folder and just use the storefront.

Offline Onima

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: How to create a language extension?
« Reply #5 on: April 25, 2015, 03:48:32 PM »
I've finally managed to translate the files. there are a few problems.

In install.php the long code after

$this->db->query("INSERT INTO ".DB_PREFIX."country_descriptions 
(`country_id`,`language_id`, `name`) VALUES

has (72,$new_language_id,'Finlandia')

The actual name of the language is Finland. Could this cause a  problem?

-----

Am I supposed to translate the end of install.php

$this->db->query("INSERT INTO ".DB_PREFIX."stock_statuses
(`stock_status_id`,`language_id`, `name`) VALUES 
(1, $new_language_id, 'Varastossa'),
(2, $new_language_id, 'Loppuunmyyty'),
(3, $new_language_id, 'Esitilaus');
");

$this->db->query("INSERT INTO ".DB_PREFIX."length_class_descriptions
(`length_class_id`, `language_id`, `title`, `unit`) VALUES
(1, $new_language_id, 'Senttimetri', 'cm'),
(2, $new_language_id, 'Millimetri', 'mm'),
(3, $new_language_id, 'Tuuma', 'in');
");

$this->db->query("INSERT INTO ".DB_PREFIX."weight_class_descriptions
(`weight_class_id`, `language_id`, `title`, `unit`) VALUES
(1, $new_language_id, 'Kilogramma', 'kg'),
(2, $new_language_id, 'Gramma', 'g'),
(5, $new_language_id, 'Pauna ', 'lb'),
(6, $new_language_id, 'Unssi', 'oz');
");

$this->db->query("INSERT INTO ".DB_PREFIX."order_statuses
(`order_status_id`, `language_id`, `name`) VALUES
(1, $new_language_id, 'Myyjä'),
(2, $new_language_id, 'Käsittely'),
(3, $new_language_id, 'Lähetys'),
(7, $new_language_id, 'Peruttu'),
(5, $new_language_id, 'Valmis'),
(8, $new_language_id, 'Hylätty'),
(9, $new_language_id, 'Peruuta peruutus'),
(10, $new_language_id, 'Epäonnistunut'),
(11, $new_language_id, 'Palautettu'),
(12, $new_language_id, 'Maksettu'),
(13, $new_language_id, 'Takaisinperintä');
");

$this->db->query("INSERT INTO ".DB_PREFIX."page_descriptions
(`page_id`, `language_id`, `name`, `title`, `seo_url`, `keywords`, `description`, `content`, `created`) VALUES
(1, $new_language_id, 'Muut sivut', '', '', '', '', '', now() ),
(2, $new_language_id, 'Etusivu', '', '', '', '', '', now() ),
(3, $new_language_id, 'Sivupyynnöt', '', '', '', '', '', now() ),
(4, $new_language_id, 'Kirjautumissivulle', '', '', '', '', '', now() ),
(5, $new_language_id, 'Virheellisen tuotteen tiedot', '', '', '', '', '', now() ),
(10, $new_language_id, 'Ylläpitosivu.', '', '', '', '', '', now() ),
(11, $new_language_id, 'Asiakastilin sivut', '', '', '', '', '', now() );
");

$this->db->query("INSERT INTO ".DB_PREFIX."global_attributes_type_descriptions
(`attribute_type_id`, `language_id`, `type_name`, `create_date`) VALUES
(1, $new_language_id, 'Tuotteen vaihtoehto', NOW()),
(2, $new_language_id, 'Lataa attribuutit', NOW());
");

$this->db->query("INSERT INTO ".DB_PREFIX."form_descriptions
(`form_id`, `language_id`, `description`) VALUES
(2,$new_language_id,'Yhteydenottolomake');
");

$this->db->query("INSERT INTO ".DB_PREFIX."field_descriptions
(`field_id`, `name`, `error_text`, `language_id`) VALUES
(14,'Syötä koodi alla olevaan kenttään:','vahvistuskoodi ei vastannut kuvaa!',$new_language_id),
(13,'Huom:','Viestin on oltava 10-1000 merkin pituinen!',$new_language_id),
(12,'E-Mail:','Sähköpostiosoite on virheellisessä muodossa tai ei kelpaa!',$new_language_id),
(11,'Etunimi:','Etunimen täytää olla 2-32 merkin pituinen!',$new_language_id);
");

$this->cache->delete('language');
$this->cache->delete('lang.fi');

----

I get a critical error when trying to install this extension. This is the log:

2015-04-20 16:11:13 - warning: AbanteCart core v.1.2.1 Invalid argument supplied for foreach() in <b>/home/my_folder/public_html/my_site/admin/controller/pages/tool/updater.php</b> on line <b>76</b>
2015-04-23 23:20:31 - warning: AbanteCart core v.1.2.1 preg_grep(): Compilation failed: nothing to repeat at offset 0 in <b>/home/my_folder/public_html/my_site/core/engine/language.php</b> on line <b>283</b>
2015-04-25 19:32:25 - database error: AbanteCart core v.1.2.1 Error: Unknown column 'created' in 'field list'
Error No: 1054
INSERT INTO page_descriptions
(`page_id`, `language_id`, `name`, `title`, `seo_url`, `keywords`, `description`, `content`, `created`) VALUES
(1, 2, 'Muut sivut', '', '', '', '', '', now() ),
(2, 2, 'Etusivu', '', '', '', '', '', now() ),
(3, 2, 'Sivupyynnöt', '', '', '', '', '', now() ),
(4, 2, 'Kirjautumissivulle', '', '', '', '', '', now() ),
(5, 2, 'Virheellisen tuotteen tiedot', '', '', '', '', '', now() ),
(10, 2, 'Ylläpitosivu.', '', '', '', '', '', now() ),
(11, 2, 'Asiakastilin sivut', '', '', '', '', '', now() );
in <b>/home/my_folder/public_html/my_site/core/database/mysql.php</b> on line <b>114</b>

Offline Onima

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: How to create a language extension?
« Reply #6 on: April 27, 2015, 01:59:33 PM »
Now I tried something simpler. I inserted the language folder 'finnish' in storefront/language folder. The flag.png is there with all the same folders and filas as in storefront/language/english.

When I try to get the language to work in system - languages, I get an error:

Error! Trying to load language with invalid path: "public_html_MySubDomain_storefront_finnish_"! in /home/my_root/public_html/MySubDomain/core/engine/language.php on line 532

The problem seems to be in the 'Edit Language Details' - directory-field. When I try to submit the directory:
 public_html/MySubDomain/storefront/finnish/
The system changes it into:
 public_html/MySubDomain/storefront/f

The manual says: "Directory: The exact directory or folder where you uploaded the language files. Should be similar to public_html/storefront/language/languagename."

So why does /public_html/MySubDomain/storefront/finnish get always reverted back to /public_html/MySubDomain/storefront ???

In the english 'Edit Language Details' - directory-field the directory is simply 'english'. No path or anything there.
If I just simply submit 'finnish' as the directory, I get an error again:
Error! Trying to load language with invalid path: "public_html_MySubDomain_storefront_finnish_"! in /home/shadowdb/public_html/MySubDomain/core/engine/language.php on line 532

storefront/languages/finnish or languages/finnish won't work either...

Offline Onima

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: How to create a language extension?
« Reply #7 on: April 28, 2015, 03:32:20 AM »
I've started the whole Abantecart system now multiple times from scratch but I still can't get the language to work.

This is the closest I've gotten...

1. Insert the finnish extension into 'extensions' folder
2. insert the folder 'finnish/storefront/language/finnish' from the finnish extension into 'public_html/MySubDomain/storefront/language/finnish'.
3. Then I do manual language install:

Quote
    To manually add a new Language click the + button

Language Name: Suomi

Code: fi

Locale: fi_FI.UTF-8,fi_FI,finnish

Directory: /finnish/ (this seems to work best even though the manual says: The exact directory or folder where you uploaded the language files. Should be similar to public_html/storefront/language/languagename.

Sort Order: If your store uses multiple languages, what order the languages are displayed in.


4. I select the language status: ON

Now I get multiple pages of storefront translations in the 'system/localization/language definitons' settings. Seven pages to be exact. But why aren't my other translations visible? It seems like only a few of my .xml translation files have been applied. The english translation has over 200 pages of language definitions.

For some reason the finnish translation stops working completely when I delete the 'idle' finnish extension from the 'extensions' folder (inserted in step 1). The flag.png isn't visible.

This is the closest I come to success. Now if I try to install the finnish extension I get critical errors and my database gets fucked up. But somehow, like a miracle, the flag.png starts working. But nothing really works anymore so I need to delete all the files and databases and re-start from scratch.

Please help me! This can't be that difficult???
« Last Edit: April 28, 2015, 03:34:06 AM by Onima »

Offline eCommerce Core

  • Administrator
  • Hero Member
  • *****
  • Posts: 1602
  • Karma: +93/-1
    • View Profile
Re: How to create a language extension?
« Reply #8 on: April 28, 2015, 07:25:52 AM »
This should be not that difficult. Probably some small mistake somewhere.
Can you pm your extension code? Put is as a download link.  I can try to install and check what is going on.
“If you’re in the luckiest one per cent of humanity, you owe it to the rest of humanity to think about the other 99 per cent.”
― Warren Buffett

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2048
  • Karma: +319/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: How to create a language extension?
« Reply #9 on: April 28, 2015, 06:10:11 PM »
1. i tried to install your extension on 1.2.1.
2. You have bugs in install.php (since v.1.2.0 we use "date_added" column name instead "created". see attachment).
3. You have a lot of xml files and all of them contains language definitions. But other "descriptions" stores in tables with "_descriptions" suffix in their name, for ex product_descriptions.
Also we call language data such descriptions of:  category,menu item name, product, block, form etc. All this stuff - it's a custom data. User must to fill it by his own.
So.. to complete translations you should copy or translate (for ex. with google translate extension) them on language edit page (see "Load missing language data" section)
4. no any issues with flag.png for me.
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: How to create a language extension?
« Reply #10 on: April 29, 2015, 11:39:35 AM »
Thank you Abolabo.

Onima please comment if this worked for you.
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

 

Powered by SMFPacks Social Login Mod