POEdit doesn't extract string in HTML tags - laravel-blade

I'm having a problem with Laravel's blade templating syntax.
When having something like:
<input placeholder="{{ __('My Tooltip') }}" />
that string won't be founded by POEdit. But on same file if I had this:
<span>{{ __('My Tooltip') }}</span>
that's OK.
I've already added a new extractor with follow configs but the problem persists.
Command: xgettext --language=Python --add-comments=TRANSLATORS: --force-po -o %o %C %K %F
An item in keywords list: -k%k
An item in input files list: %f
Source code charset: --from-code=%c
Anyone can help me?

You lie to Poedit about the content of these files, pretending they are Python, even when they are very clearly not. It’s not at all surprising that it doesn’t work to your liking. What would be surprising would be if it did. In this case, the reason seems to be clear: xgettext’s Python parser, naively trusting you and hopelessly confused as the result, sees the " in there as a start of a string literal not prefixed with __ and so skips over it.
Fix it by doing what the documentation says: use a dedicated tool to extract the string. In laravel-gettext's case that means using this command:
php artisan gettext:update
(Upcoming Poedit 2.0 will have direct support for template languages like this, but until then, you need to use the CLI tools.)

Related

shell function doesn't work in subfolder?

I have the following code that should open the Recode.xlsx inside the subf folder but doesn't
write_xlsx(mtcars, "subf/Recode.xlsx")
shell("subf/Recode.xlsx", wait=FALSE)
The following code works, so if anyone has an idea on why it doesn't work it would help me
write_xlsx(mtcars, "Recode.xlsx")
shell("Recode.xlsx", wait=FALSE)
Here’s what the documentation of the shell function says (emphasis mine):
shell is a more user-friendly wrapper for system. To make use of Windows file associations, use shell.exec.
And here is another bit of relevant information from the shell.exec documentation:
To be interpreted as relative, the path also needs to use backslashes as separators (at least in Windows 10).
So the following is the correct usage:
shell.exec("subf\\Recode.xlsx")

How can I get "canonical" name of the text encoding of current Atom active editor?

I have recently adding a fix for atom-script package to resolve garbled text output in compile&run Java code in non-English Windows environment. (Issue #1166, PR #2471)
After this, now in release script package 3.32.1, javac has options -J-Dfile.encoding=UTF-8 and -encoding UTF-8 both. (diff is here) I have just realized that it is better to provide actual encoding of the current active editor which holds the target source code for -encoding option. After some research, I have learnt that the encoding can be acquired by
atom.workspace.getActiveTextEditor().getEncoding()
but, after I have tested in Japanese edition Windows, it returns shiftjis and this is not valid encoding name for javac command line option. (It should be MS932, SJIS or something similar.) I have no idea where I can get this type of encoding names without writing large conversion table for all possible encoding names. Is there any good utility for such purpose?
EDIT:
For demonstrating what I have supposed to do, I have created branch on my fork. Diff is here.
Getting current source code editor encoding by
const fileEncoding = getJavaTextEncodingName(atom.workspace.getActiveTextEditor().getEncoding())
and pass it to javac via
const cmd = `javac -encoding ${fileEncoding} -J-Dfile.encoding=UTF-8 -Xlint -sourcepath '${sourcePath}' -d '${tempFolder}' '${filepath}' && java -Dfile.encoding=UTF-8 -cp '${tempFolder}' ${classPackages}${className}`
And, function "getJavaTextEncodingName()" is the core of the question.
function getJavaTextEncodingName(atomTextEncodingName) {
switch (atomTextEncodingName) {
case "shiftjis" :
return "MS932"
}
return "UTF-8"
}
It is obvious that this is converting "shiftjis" to "MS932" but, it is not so beautiful if we implement all possible encoding name conversions here, so I am seeking better alternative.

Avoid rendering of specific .md files from blogdown::serve_site()

I have a file located at
content/post/data_for_posts/my_file.md
I have it there because it's quite easy to do htmltools::includeMarkdown("data_for_posts/my_file.md") and recycle this file in different posts.
My problem is that when I serve_site() this creates a public/post/data_for_posts/index.html, which means, it gets posted to my website (as a January 1 of 0001). I guess I could change the date to year 10000, but I would rather handle it the way I handle the .Rmd and other files, as suggested here
I have tried to modify my config.toml but have not managed to solve the issue.
ignoreFiles = ["\\.Rmd$", "\\.Rmarkdown$", "_files$", "_cache$", "content/post/data_for_posts/my_file.md"]
Here are a couple techniques that I use to do this:
Rename data_for_posts/my_file.md so it uses a file extension that hugo does not interpret as a known markup language, for example change .md to .markd or mdn.[*]
Rename data_for_posts/my_file.md so it includes a string that you will never use in a real content file, for example data_for_posts-UNPUBLISHED/my_file.md. Then add that string (UNPUBLISHED or whatever) to your config ignoreFiles list.[**]
[*] In the content/ directory, a file with one of the following file extensions will be interpreted by hugo as containing a known markup language: .ad, .adoc, .asciidoc, .htm, .html, .markdown, .md, .mdown, .mmark, .pdc, .pandoc, .org, or .rst (this is an excerpt of something I wrote).
[**] The strings listed in ignoreFiles seem to be case sensitive so I like to use all-upper-case characters in my ignored file names (because I never use upper-case chars in real content file names). Also note that there is no need to specify the path and my experience is that path delimiters (/ or \) cause problems.

How to use a template in vim

This is really a newbie question - but basically, how do I enable a template for certain filetypes.
Basically, I just want the template to insert a header of sorts, that is with some functions that I find useful, and libraries loaded etc.
I interpret
:help template
the way that I should place this in my vimrc
au BufNewFile,BufRead ~/.vim/skeleton.R
Running a R script then shows that something could happen, but apparently does not:
--- Auto-Commands ---
This may be because a template consists of commands (and there are no such in skeleton.R) - and in this case I just want it to insert a text header (which skelton.R consist of).
Sorry if this question is mind boggeling stupid ;-/
The command that you've suggested is not going to work: what this will do is run no Vim command whenever you open ~/.vim/skeleton.R
A crude way of achieving what you want would be to use:
:au BufNewFile *.R r ~/.vim/skeleton.R
This will read (:r) your file whenever a new *.R file is created. You want to avoid having BufRead in the autocmd, or it will read the skeleton file into your working file every time you open the file!
There are many plugins that add a lot more control to this process. Being the author and therefore completely biased, I'd recommend this one, but there are plenty of others listed here.
Shameless plug:
They all work in a relatively similar way, but to explain my script:
You install the plugin as described on the linked page and then create some templates in ~/.vim/templates. These templates should have the same extension as the 'target' file, so if it's a template for .R files, call it something like skeleton.R. In your .vimrc, add something like this:
let g:file_template_default = {}
let g:file_template_default['R'] = 'skeleton'
Then create your new .R file (with a filename, so save it if it's new) and enter:
:LoadFileTemplate
You can also skip the .vimrc editing and just do:
:LoadFileTemplate skeleton
See the website for more details.
Assume that your skeletons are in your ~/.vim/templates/ directory, you can put this
snippet in your vimrc file.
augroup templates
au!
" read in templates files
autocmd BufNewFile *.* silent! execute '0r ~/.vim/templates/skeleton.'.expand("<afile>:e")
augroup END
Some explanation,
BufNewFile . = each time we edit a new file
silent! execute = execute silently, no error messages if failed
0r = read file and insert content at top (0) in the new file
expand(":e") = get extension of current filename
see also http://vim.wikia.com/wiki/Use_eval_to_create_dynamic_templates
*fixed missing dot in file path
Create a templates subdirectory in your ~/.vim folder
$ mkdir -p ~/.vim/templates
Create a new file in subdirectory called R.skeleton and put in the header and/or other stuff you want to automagically load upon creating a new ".R " file.
$ vim ~/.vim/templates/R.skeleton
Then, add the following to your ~/.vimrc file, which may have been suggested in a way by "guest"
autocmd BufNewFile * silent! 0r $HOME/.vim/templates/%:e.skeleton
Have a look at my github repository for some more details and other options.
It's just a trick I used to use .
It's cheap but If you ain't know nothing about vim and it's commands it's easy to handle.
make a directory like this :
~/.vim/templates/barney.cpp
and as you konw barney.cpp should be your template code .
then add a function like ForUncleBarney() to end of your .vimrc file located in ~/.vimrc
it should be like
function ForBarneyStinson()
:read ~/.vim/templates/barney.cpp
endfunction
then just use this command in vim
:call ForBarneyStinson()
then you see your template
as an example I already have two templates for .cpp files
:call ForBarney()
:call ACM()
sorry said too much,
Coding's awesome ! :)
Also take a look at https://github.com/aperezdc/vim-template.git.
I use it and have contributed some patches to it and would argue its relatively full featured.
What about using the snipmate plugin? See here
There exist many template-file expanders -- you'll also find there explanations on how to implement a rudimentary template-file expander.
For my part, I'm maintaining the fork of muTemplate. For a simple start, just drop a {ft}.template file into {rtp}/template/. If you want to use any (viml) variable or expression, just do. You can even put vim code (and now even functions) into the template-file if you wish. Several smart decisions are already implemented for C++ and vim files.

Associate .Rnw with vim latex suite

This I am sure is really basic stuff. I am just beginning using gvim and latex-suite. However I would like latex-suite to load when I edit a sweavefile with.Rnw extension.
my .vimrc looks like this
" These settings are needed for latex-suite
filetype indent on
filetype plugin on
filetype on
let g:tex_flavor='latex'
set grepprg=grep\ -nH\ $*
"let g:Tex_Folding=0 "I don't like folding.
set iskeyword+=:
and I guess there is some option I can set here that makes vim treat Rnw as .tex?
Put a file in /usr/share/vim/vimfiles/ftdetect (for global) or .vim/ftdetect (for local) called Rnw.vim that looks something like this:
" Vim filetype detection plugin
" Language: sweavefile
autocmd BufRead,BufNewFile *.Rnw set filetype=tex
Edit: I'm pretty sure you could put this autocommand in your .vimrc too, since that's loaded on program start, before any files are loaded, but this is directory the natural place for filetype detection.
Edit: If you would like to give these files some treatment different from TeX, you could instead set the filetype to rnw, add scripts to the ftplugin, indent, and syntax directories as necessary, most likely sourcing the TeX scripts and then doing your own stuff.
Hope these pointers will help:
Have a look at this: http://feferraz.net/en/P/Sweave_Syntax_Highlighting_in_vim.
This was also previously on R-Help.

Resources