Can't get String Overrides module to work for me - drupal

I installed the String Overrides module and I have two entries in Site Configuration, one for Arabic and the other for English. I had put "Create Advertisement" inside of "Original field (English)" and some Arabic text inside "Replacement field." Nothing happened; no replacement was done.
I know there is something about wrapping the text in the t() function, but I do not know where to do it from. It is easy to do that in the case of replacing a field name but not here in this case. Can I have some help from you? I am using Drupal 6.19.

As reported in the project page, String Overrides can be used to replace anything that is passed through t(); if the English string is not used from any modules, you will not see the Arabic string being used.
If you are using "Create Advertisement" in your module, then the module should contain a call to t("Create Advertisement"). t() is case sensitive; if you are overriding "Create Advertisement," but the string used is "Create advertisement," then the string it will not be shown in Arabic.
I also think Arabic must be the language set for the page being shown.

Related

poedit doesn't recognize _x

My .po file contains:
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
"_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_ex:1,2c;"
"esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
And my php/wordpress code contains:
_x( 'Add New', $this->post_type , $domain ),
I know that Poedit is scanning that file (all the other translatable strings are picked up on "update catalog", and share the same domain). And if I change _x to __ (and remove the context parameter) it picks that one as well. But as it is written, the "Add New" string simply wont show in PoEdit.
Even if I add manually the string to the po file, it will put it in the "obsolete strings" after trying to update to .po file from sources...
Would have thought that the "_x:1,2c;" bit would be enough to pick up the string, but it never does.
Is there something I'm doing wrong, or have I encountered an actual bug?
See the documentation for _x() at http://codex.wordpress.org/Function_Reference/_x — the second argument is context, which is a string included in the PO together with the source text to disambiguate otherwise identical strings with different meaning. The codex page above has an example; another one is e.g. "Open" that could be used in different context, so the programmer would use e.g. "File menu" as the context.
The important part is that it is handled the same way as the text to be translated. The text has to be a string literal for xgettext to extract it and so does the context (it has to be: it's something that goes into the PO file!).
$this->post_type is not a literal, which is why xgettext doesn't recognize it. There's no way it could know what the post_type value could be at runtime and so it couldn't possibly know what to write into the created PO file.
To fix this, you need to use _x() with at least the first two arguments string literals.

Getting input as hindi character from textbox and storing it to database

I am using asp.net and c# in my application and Mysql as Database.I want to take input from user in hindi and store it in database and retrieve it.
When I am storing the hindi characters in from Mysql database it is working fine for me but when I am using textbox to input a hindi characters it is showing me ?????????.
I guess the problem is the aspx page does not set to support hindi characters.Please tell me the way to achieve this.
I guess using UTF-8 encoding on your Http request and responses would solve it. What is your requestEncoding and responseEncoding in your Web.config file set to currently?
See more on the <globalization> tag here:
http://msdn.microsoft.com/en-us/library/hy4kkhe0(v=VS.100).aspx
try this:-
// mytable=2 fields id(auto increment),title(nvarchar(max))
string title = "बिलाल";
SqlCommand cmd = new SqlCommand("insert into mytable values (N'" + title + "')", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Haha.. Oh the memories (and I only had to deal with spanish which fits into the default latin1).
So I don't know the MS side of the stack, but I assume it's the same types of solutions as Java. Namely you should always assume UTF-8, and thus make your Content-Type HTML responses always show UTF-8 so that browsers know to encode POST data in UTF-8. You should always inspect the encoding type of HTML POST's just in case you have a browser that ignored the encoding of the HTML form (someone might be using curl/wget/custom-browser). You need to learn how in MS-land to convert from one encoding type into UTF-8 (in java, for reference, we just say String s = new String(bytes, encoding_name))
Assuming that MS's stack uses UTF-16 or UCS-32 or whatever so that UTF-8 is easy to extract, next comes the mysql layer.
This includes 2 things..
1) column encoding MUST be set to UTF8.. It's not obvious at all how to do it, and even the spelling is annoying.. Just google it.. "create database foo default character set UTF8" (approximate syntax), or if you're worried for some reason, do it at the table level "create table foo (..) character set UTF8" (approximate syntax).. Or if the table is already there, take EVERY column that can take arbitrary web-form text (possibly including login-name, but not columns like enumerated varchars - as it would waste index space - even though you'd think it wouldn't) "alter table foo change name varchar(255) character set UTF8" (approximate syntax).
2) You MUST make the ODBC connection (jdbc in java, don't know in MS), encode all in/out characters at UTF-8. There are two parameters I set (use-unicode, and character-set=UTF-8) (approximate parameter names).
Google it all, but this should point you in the right direction.
Test the existing DB by connecting to mysql both with character-set=UTF8 and latin1.. You'll see totally different output in your text-data when connected as each encoding. If you're lucky, you already got the data in correctly.. Otherwise you'll have to regenerate ALL the data, or perform some very clever character conversion hacks like I had to do once upon a time (painful stuff).

ASP.NET - Reading quoted text from local resource file

i'm using a little javascript in my website for my navigation bar, which is made up of a few ImageButton controls. in the code behind i have this:
Dim homeImage As String = GetLocalResourceObject("HomeImage")
imgBtnHome.Attributes.Add("OnMouseOver", HomeImage)
and in the resx file, i've tried these, but they don't work: (note the single and double quotes)
key: HomeImage value: "this.src='images/HomeImage.gif'"
key: HomeImage value: "this.src=&apos;images/HomeImage.gif&apos;"
can anyone tell me what i'm doing wrong? is it even possible to read "quoted" text from a local resource file?
Yes, you can store quotes in a resx string value. If you look at the XML that's generated for a resource file, you'll see that the quotes are in the value entries.
However, your script isn't going to work with quotes around it. Think of it this way - say you wanted to pop up an alert box. You would do:
imgBtnHome.Attributes.Add("OnMouseOver", "alert('hi')")
NOT
imgBtnHome.Attributes.Add("OnMouseOver", """alert('hi')""");
You're passing in a string value for the script, not a quoted string value. Try removing the double quotes altogether, and leave the single quotes.

html injection question

Using FreeTextBox, I'm capturing HTML-formatted text. The purpose is to allow a website owner to update their web page content on a few pages. I have the system completed except for knowing what to do with the resultant HTML markup.
After the page editor completes their work, I can get the output from FreeTextBox, in html format, like so: <font color="#000080"><b>This is some text.</b></font>
I tried storing it as escaped markup in web.config, but that didn't work since it kept hosing the tags even after I changed them to escaped characters, like so: <font color="#000080">
The reason I wanted to store this kind of string as a key in web.config is that I could successfully store a static string, set a lebel's value to it, and successfully render the text. But when I try to escape it, it gets reformatted in web.config by .Net somehow.
So I escaped all the characters, encoded them as Base64 and stored that. Then on page_load, I tried to decode it, but it just shows up as text, with all the html tags showing as well - it doesn't get rendered. I know a million people use this control, but I'm damned if I can figure out how to do it right.
So here's my question: how can I inject the saved HTML into an edited page so it shows up in browsers like the editor wants it to look?
Try Server.HtmlDecode to output the HTML to the screen.
As a side note, I prefer to use CKEditor for html-formatted input. I found it is the better option among all options (FreeTextBox, TinyMCE, anything else?) and it has got completely rewritten and faster in the version 3.0!
In case anyone comes here for the answer, here's one way to do it.
I had initial problems with web.config changing some of the HTML tags upon storage, so we use B64 encoding (may not be necessary). Store the saved html markup to an AppSettings key in web.config as Base64 encoding, using this for your setting update function. Add error checking and whatever else you need it to do:
'create configuration object
Dim cfg As Configuration
cfg = WebConfigurationManager.OpenWebConfiguration("~")
'get reference to appsettings("HTMLstring")
Dim HTMLString As KeyValueConfigurationElement = _
CType(cfg.AppSettings.Settings("HTMLstring"), KeyValueConfigurationElement)
'get text entered by user and marked up with HTML tags from FTB1, then
'encode as Base64 so we can store it as XML-safe string in web.config
Dim b64String As String = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(FTB1.Text))
'save new value into web.config
If Not HTMLString Is Nothing Then
HTMLString.Value = b64String
cfg.Save()
End If
Next, add a Literal control to the aspx markup:
<asp:Literal id="charHTML" runat="server"/>
To add the saved HTML to the post-edited page, do the following in Page_Load:
'this string of HTML code is stored in web.config as Base64 to preserve XML-unsafe characters that come from FreeTextBox.
Dim injectedHTML As String = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(AppSettings("HTMLstring")))
'the literal control will directly inject this HTML instead of encoding it
charHTML.Mode = LiteralMode.PassThrough
'set the value
charHTML.Text = injectedHTML
Hope this helps. sF

How to select between include files

I am working on adding a mulit-language feature to an asp classic site. I was trying to do this by using if else statements to select the include I want to load. After a bit of research I found out that includes files are loaded up before any code is handled.
How can I get around this issue and load up the proper include files? Is there a better way of doing this?
Thanks!
You can't, as you've discovered, dynamically choose includes. Includes are handled statically before any script is executed.
The next best thing is Server.Execute. You can use logic to choose what additional files to execute, however whether this fits with your solution is another matter. What do your includes currently contain?
Another approach would be place your "multi-language" choices in some data format such a set of CSV files or XML files. Your code would then load the appropriate "language file".
After countless hours I think I finally came up with a solution. I create xml files for each language (en.xml, fr.xml) with a super simple structure (just a label element with an id and value).
By using an attribute that has a similar name to the label I want to replace I can figure out where everything needs to go, and just pull the value.
I'm not sure if this idea helps, but you could dim the language string variables in one ASP file and then set the variables in separate ASP functions. Then your if statements can call the proper function to set the ASP language string variables. You would not be breaking out the language string into separate files, but it might accomplish what you are trying to achieve.
For example:
dim str1, str2
sub SetLangX
str1 = "String val 1 for lang X"
str2 = "String val 2 for lang X"
end sub
sub SetLangY
str1 = "String val 1 for lang Y"
str2 = "String val 2 for lang Y"
end sub
It can be done - just use include virtual instead of file
edit
I stand corrected - obviously i tried too hard to forget those dark ages.
Years ago i worked on a project where we would create a "container page" for every language version an then include the respective portion of constants.
A working spinoff is still running and if you check the page source of this site you can get an idea how we plugged the pages together.
Some of the included scripts identified by their SVN id tags even included more scripts and maintaining this slowly turned into a nightmare.
I'm sorry i was wrong about the conditional include and there should be a better solution than the one mentioned above.

Resources