Re: [Ilugc] marking strings for translation in emacs

2011-05-11 Thread Vijay Kumar B .
Kenneth Gonsalves lawgon@... writes:

 
 hi,
 
 in python to mark strings for translation one does this:
 
 string: somestring
 marked string: _(somestring)
 
 and in django templates:
 string: somestring
 marked string: {% trans somestring %}
 
 can anyone suggest a very quick and easy way of doing this?

Add the following code (simple and not so accurate code) to your ~/.emacs file,
and restart emacs. Open up a Python module, move the cursor to a string and
press C-c t.

--
(defun py-mark-trans ()
  (interactive)
  (save-excursion
(search-backward \)
(insert _()
(search-forward \)
(search-forward \)
(insert 

(defun my-python-hook ()
(define-key python-mode-map [?\C-c?t] 'py-mark-trans))

(add-hook 'python-mode-hook 'my-python-hook)
-

Regards,
Vijay

___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] marking strings for translation in emacs

2011-05-11 Thread Kenneth Gonsalves
On Wed, 2011-05-11 at 06:21 +, Vijay Kumar B. wrote:
 Add the following code (simple and not so accurate code) to your
 ~/.emacs file,
 and restart emacs. Open up a Python module, move the cursor to a
 string and
 press C-c t.
 
 --
 (defun py-mark-trans ()
   (interactive)
   (save-excursion
 (search-backward \)
 (insert _()
 (search-forward \)
 (search-forward \)
 (insert 
 
 (defun my-python-hook ()
 (define-key python-mode-map [?\C-c?t] 'py-mark-trans))
 
 (add-hook 'python-mode-hook 'my-python-hook) 

thanks - works well, but one more thing - sometimes the strings are
marked with '' and not  - how to handle this case?
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] marking strings for translation in emacs

2011-05-11 Thread Kenneth Gonsalves
On Wed, 2011-05-11 at 07:23 +, Vijay Kumar B. wrote:
 Kenneth Gonsalves lawgon@... writes:
  thanks - works well, but one more thing - sometimes the strings are
  marked with '' and not  - how to handle this case?
 
 The following code handles both the quoting styles.
 
 --
 (defun py-mark-trans ()
   (interactive)
   (save-excursion
 (re-search-backward [\'])
 (insert _()
 (re-search-forward [\'])
 (re-search-forward [\'])
 (insert  

coolness
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] marking strings for translation in emacs

2011-05-11 Thread Kumar Appaiah
Hi.

On Wed, May 11, 2011 at 07:00:30AM +0530, Kenneth Gonsalves wrote:
 in python to mark strings for translation one does this:
 
 string: somestring
 marked string: _(somestring)
 
 and in django templates:
 string: somestring
 marked string: {% trans somestring %}
 
 can anyone suggest a very quick and easy way of doing this?

The macro recommended is good; another method would be to simply use a
careful keyboard macro.

For instance, go to the top of the buffer, then:

C-x ( (start recording)
C-s  (search for \)
C-b ( (prepend the parenthesis)
C-s  C-s (search for the closing paren)
C-f ) (closing paren)
C-x )

Then you can basically just keep doing C-x e, or do
C-u 100 C-x e to run the macro, say 100 times.

The advantage of this method is that you don't need to write Emacs
Lisp. The disadvantage is that it is prone to errors and not flexible.

See http://www.emacswiki.org/emacs/KeyboardMacros for details.

Kumar
-- 
:
[ GNU/Linux One Stanza Tip (LOST) ]###
   
Sub : Booting M$ from secondary HDD  LOST #318

other=/dev/hdb1 | Make an entry in  /etc/lilo.conf  as
  label=DOS | shown to boot M$ from secondary HDD.
  table=/dev/hdb| This leads BIOS to believe that /hdb
  map-drive = 0x80  | (secondary HDD) is the  primary  and
  to = 0x81 | boots M$/Win normally ... Handy when
  map-drive = 0x81  | you swap your HDDs around on  adding
  to = 0x80 | a second hard disk ...
 
[perisat (at) yahoo.com]##
:
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] marking strings for translation in emacs

2011-05-11 Thread Kenneth Gonsalves
On Wed, 2011-05-11 at 07:27 -0500, Kumar Appaiah wrote:
 Then you can basically just keep doing C-x e, or do
 C-u 100 C-x e to run the macro, say 100 times. 

the only problem with this is that it will mark *every* string for
translation. Actually a human is needed to decide which strings to mark.
The method given works like a dream.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


[Ilugc] marking strings for translation in emacs

2011-05-10 Thread Kenneth Gonsalves
hi,

in python to mark strings for translation one does this:

string: somestring
marked string: _(somestring)

and in django templates:
string: somestring
marked string: {% trans somestring %}

can anyone suggest a very quick and easy way of doing this?
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] marking strings for translation in emacs

2011-05-10 Thread Balachandran Sivakumar
Hi,

On Wed, May 11, 2011 at 7:00 AM, Kenneth Gonsalves
law...@thenilgiris.com wrote:
 hi,

 can anyone suggest a very quick and easy way of doing this?

   I haven't worked much on translation as such. But if you choose
type it as somestring and then use substitute option for
substituting somestring with {% trans somestring %}, then you can
do either

1) M-x replace-string
   Give the string you want to replace, sometring in this case
and then the string to replace it with, {% trans somestring %} in
this case. This would replace All occurrences of somestring with {%
trans somestring %}.

2) M-x query-replace
  Same as above, except that it highlights each occurrence one
by one and asks if you need to replace. You can press 'y' or 'n' and
keep going.


  Sorry if you meant something else and the reply is not relevant. Thanks

-- 
Thank you
Balachandran Sivakumar

Arise Awake and stop not till the goal is reached.

Mail: benignb...@gmail.com
Blog: http://benignbala.wordpress.com/
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] marking strings for translation in emacs

2011-05-10 Thread Kenneth Gonsalves
On Wed, 2011-05-11 at 10:52 +0530, Balachandran Sivakumar wrote:
 I haven't worked much on translation as such. But if you choose
 type it as somestring and then use substitute option for
 substituting somestring with {% trans somestring %}, then you can
 do either
 
 1) M-x replace-string
Give the string you want to replace, sometring in this case
 and then the string to replace it with, {% trans somestring %} in
 this case. This would replace All occurrences of somestring with {%
 trans somestring %}.
 
 2) M-x query-replace
   Same as above, except that it highlights each occurrence one
 by one and asks if you need to replace. You can press 'y' or 'n' and
 keep going.
 
 
   Sorry if you meant something else and the reply is not relevant.
 Thanks
 
 

I meant something else. Marking strings for translation means each
string is different. At present what I do is:
1. mark the string
2. C-W
3. type _(  this will autocomplete to _() with the cursor between the
quotes
4. C-y 
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc