× Here you can get community support related to CSLookup.

How to translate?

  • ideias
  • Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 11 months ago #463 by ideias
How to translate? was created by ideias
The extension is great. But I would like to make a translation of the Countries list. Is it possible to use the normal code for translations (i.e: J.Text::...etc) in the JS script, instead of the single name of the country?
Also I would like to integrate the plugin in the com_eztestimonial or the Alfcontact form and maybe also in the register form for new users. Mybe I'm asking too much... :)

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago #465 by admin
Replied by admin on topic How to translate?
No problem.
The country/state names are embedded in the Javascript code, so you should replace them into this file. I've used an existing library, adding some features:
/*
	*	Original script by: Shafiul Azam
	*	ishafiul@gmail.com
	*	Version 5.0
	*	Modified by: selfget.com
	*	info@selfget.com

	*	Description:
	*	Inserts Countries and/or States as Dropdown List
	*	How to Use:

		In Head section:
		<script type="text/javascript" src="countries.js"></script>

		In Body Section:
		Select Country:
		<select onchange="print_state('state',this.selectedIndex);" id="country" name ="country"></select>
		<br />
		City/District/State: <select name="state" id="state"></select>
		<script language="javascript">print_country("country");</script>

		Added capability to get initial value and to use this to set selected option

	*
	*	License: OpenSource, Permission for modificatin Granted, KEEP AUTHOR INFORMATION INTACT
	*	Author's Website: http://shafiul.progmaatic.com
	*	Author's Website: http://www.selfget.com
	*
*/

About the second question, I didn't understand how can I help you with integrations. Just let me know...

Kind regards,
Luigi

Please Log in or Create an account to join the conversation.

  • ideias
  • Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 11 months ago #466 by ideias
Replied by ideias on topic How to translate?
Thanks for the answer. But what I really would like is to use the plugin in a multilingual site. So, I wonder f it's possible to change your original settings in the js file, in order to have a format like (I know the following code is incorrect, but is just to give you the idea):

var country_arr = new Array("<?php echo JText::_('Afghanistan');?>", "<?php echo JText::_('Albania');?>", ....

instead of the original

var country_arr = new Array("Afghanistan", "Albania", ....,

and then make it possible to translate the country names to different languages, with the .ini language files. Something like:

AFGHANISTAN="Afeganistão" (pt-PT)

AFGHANISTAN="Afghanistan" (fr-FR)

Also, I'd like to know a way to define a selected country, without have to hack the components in which I want to use the plugins. Perhaps in the js script?

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago #467 by admin
Replied by admin on topic How to translate?
About the first point, you want to execute php code inside a javascript file, and this is not impossible, but a little bit tricky to get.

The reason is when the browser requests a .js file, the webserver doesn't execute any php code, just send the .js file.

If you search on the web you will find many "workaround" for this problem, but nothing really "clean".

About the second question, the js searches for an existing selected value in the HTML and preserves it. So you could just assing your filed to the HTML field.

Kind regards,
Luigi

Please Log in or Create an account to join the conversation.

  • ideias
  • Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 10 months ago #590 by ideias
Replied by ideias on topic How to translate?
Hello, again.
I've been a bit ill for the last month, and that's why I didn't answered before, sorry.

Thanks for your precious help. I've made the translation as you said, and it worked. :) But, translating the js file to Portuguese, some fields became alfabeticaly unordered (for example: Central African Republic is Repúbica Centro-Africana in Portuguese). Is it possible to change the order of the fields? In that case, I presume I must also change the state/city order, too, isn't it?

I just don't get the way to define the selected country. You say I can make it in the html, but... which html are you talking? Is it in the CSLookup?

Also, I wonder if it is possible to change the js code in order to display the flag of the country, instead of the name. It would be more in line with the template style. Do you think there's any way to do this?

Thank you very much, onde more.

Please Log in or Create an account to join the conversation.

More
11 years 10 months ago #596 by admin
Replied by admin on topic How to translate?
Hi,
as you can see in the .js header, this script is not mine, I just modified it to support initial select. So if you require major changes to the javascript code I cannot support you, you should try to contact the original author.

About the first question, the JS builds two arrays. To have items sorted alphabetically, you must sort the items into array.

About the second question, if your input/select field has an initial value, CSLookup just replace the field with a select field with all items, and tries to select your initial value automatically. So there is nothing you should do.

About your third question, I think this is a deep change, it is possible for sure, but can't figure out a simple way just like that... I'm not so good :)

Kind regards,
Luigi

Please Log in or Create an account to join the conversation.

Time to create page: 0.145 seconds