[prev in list] [next in list] [prev in thread] [next in thread] 

List:       aspell-user
Subject:    [Aspell-user] How to change Language during run-time
From:       Nikunj Manocha <nikunj.manocha () plateau ! com>
Date:       2005-06-06 21:02:21
Message-ID: 53C527E2212BC849B14091DACFA944C85FCC53 () newmail ! plateau ! com
[Download RAW message or body]

Hi All,

  Am calling the Aspell Library through my Application. I start Aspell in
Default English Language Dictionary and (as per User's interaction) I wish
to change to the Spanish Dictionary (dynamically). I am unable to do this. I
am appending the code I am using to do this. What am I doing wrong?

           AspellCanHaveError * ret;
	AspellSpeller *speller = (AspellSpeller *)handle;
	AspellConfig *config = aspell_speller_config(speller);
	
	const char * val2 = aspell_config_retrieve(config, "lang");
	//check_for_config_error(config);
	if (val2)
	  printf("%s = \"%s\"\n", "lang", val2);

	AspellConfig * spell_config2 = aspell_config_clone(config);
	//delete_aspell_config(config);
	//delete_aspell_speller(speller);


	
         aspell_config_replace(spell_config2, key,value);
	ret = new_aspell_speller(spell_config2);

     
	if (aspell_error(ret) != 0) {
                   ThrowJASpellException(env, aspell_error_message(ret));
                   delete_aspell_can_have_error(ret);
                   return 0;
         }

	AspellSpeller *speller2 = to_aspell_speller(ret);
	const char * val = aspell_config_retrieve(spell_config2, "lang");
	//check_for_config_error(config);
	if (val)
	  printf("%s = \"%s\"\n", "lang", val);

	AspellConfig *config2 = aspell_speller_config(speller2);
	const char * val3 = aspell_config_retrieve(config2, "lang");
	//check_for_config_error(config);
	if (val3)
	  printf("%s = \"%s\"\n", "lang", val3);

	return (jint)speller2;

The above prints out :

lang = "en"
lang = "es"
lang = "en"

Why so? Someone please help. I am new to Aspell (as well as C programming).

Note: I am calling the Aspell C API using JNI calls from Java.

Any help will be appreciated. Thanks.


Best Regards,
Nikunj Manocha

www.plateau.com <www.plateau.com> 
703-292-0316


[Attachment #3 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2658.2">
<TITLE>How to change Language during run-time</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2 FACE="Arial">Hi All,</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">&nbsp; Am calling the Aspell Library through my \
Application. I start Aspell in Default English Language Dictionary and (as per User's \
interaction) I wish to change to the Spanish Dictionary (dynamically). I am unable to \
do this. I am appending the code I am using to do this. What am I doing \
wrong?</FONT></P>

<P><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
AspellCanHaveError * ret;</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT \
SIZE=2 FACE="Arial">AspellSpeller *speller = (AspellSpeller *)handle;</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">AspellConfig \
*config = aspell_speller_config(speller);</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">const char * \
val2 = aspell_config_retrieve(config, &quot;lang&quot;);</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 \
FACE="Arial">//check_for_config_error(config);</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">if \
(val2)</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 \
FACE="Arial">&nbsp; printf(&quot;%s = \&quot;%s\&quot;\n&quot;, &quot;lang&quot;, \
val2);</FONT> </P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">AspellConfig \
* spell_config2 = aspell_config_clone(config);</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 \
FACE="Arial">//delete_aspell_config(config);</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 \
FACE="Arial">//delete_aspell_speller(speller);</FONT> </P>
<BR>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
aspell_config_replace(spell_config2, key,value);</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">ret = \
new_aspell_speller(spell_config2);</FONT> </P>

<P><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp;&nbsp; </FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">if \
(aspell_error(ret) != 0) {</FONT> <BR><FONT SIZE=2 \
FACE="Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
ThrowJASpellException(env, aspell_error_message(ret));</FONT> <BR><FONT SIZE=2 \
FACE="Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
delete_aspell_can_have_error(ret);</FONT> <BR><FONT SIZE=2 \
FACE="Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
return 0;</FONT> <BR><FONT SIZE=2 \
FACE="Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT> </P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">AspellSpeller \
*speller2 = to_aspell_speller(ret);</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">const char * \
val = aspell_config_retrieve(spell_config2, &quot;lang&quot;);</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 \
FACE="Arial">//check_for_config_error(config);</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">if \
(val)</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 \
FACE="Arial">&nbsp; printf(&quot;%s = \&quot;%s\&quot;\n&quot;, &quot;lang&quot;, \
val);</FONT> </P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">AspellConfig \
*config2 = aspell_speller_config(speller2);</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">const char * \
val3 = aspell_config_retrieve(config2, &quot;lang&quot;);</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 \
FACE="Arial">//check_for_config_error(config);</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">if \
(val3)</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 \
FACE="Arial">&nbsp; printf(&quot;%s = \&quot;%s\&quot;\n&quot;, &quot;lang&quot;, \
val3);</FONT> </P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">return \
(jint)speller2;</FONT> </P>

<P><FONT SIZE=2 FACE="Arial">The above prints out :</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">lang = &quot;en&quot;</FONT>
<BR><FONT SIZE=2 FACE="Arial">lang = &quot;es&quot;</FONT>
<BR><FONT SIZE=2 FACE="Arial">lang = &quot;en&quot;</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Why so? Someone please help. I am new to Aspell (as well \
as C programming).</FONT> </P>

<P><FONT SIZE=2 FACE="Arial">Note: I am calling the Aspell C API using JNI calls from \
Java.</FONT> </P>

<P><FONT SIZE=2 FACE="Arial">Any help will be appreciated. Thanks.</FONT>
</P>
<BR>

<P><FONT SIZE=2 FACE="Arial">Best Regards,</FONT>
<BR><FONT SIZE=2 FACE="Arial">Nikunj Manocha</FONT>
</P>

<P><A HREF="www.plateau.com"><U><FONT COLOR="#0000FF" SIZE=2 \
FACE="Arial">www.plateau.com</FONT></U></A> <BR><FONT SIZE=2 \
FACE="Arial">703-292-0316</FONT> </P>

</BODY>
</HTML>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic