Lua find "\x" in the player names - lua

the players on my server are joining with Emojis on his names and that is not permitted, I tried to create a if check, but it doesn't work properly
if string.find(playerName, "%^") or string.find(playerName, '%\') then
deferrals.done("Por favor, elimine sus emojis y códigos de color de su nombre.")
end

The syntax highlighting already tells you what's wrong: \ is used in Lua as an escape character, so the ' behind it doesn't close the string which instead goes on until the next ' smoewhere in your code. Use \\ if you want a single \
if playerName:find("%^") or playerName:find("%\\") then
deferrals.done("Por favor, elimine sus emojis y códigos de color de su nombre.")
end
By the way; if you don't need patterns in your search, you can disable them by passing false as the second argument to string.find:
if playerName:find([[^]], 1, false) or playerName:find([[\]], 1, false) then
deferrals.done("Por favor, elimine sus emojis y códigos de color de su nombre.")
end
And just in case, try adding an or true to the condition, so it activates for all player names; that way you can find out if it's the condition itself that fails, or the code inside the if block.

Related

Incorrect translations when implementing pluralization in ICU message format. I'm using react-intl (format.js)

It seems like using pluralization in ICU message format is not dependable when combined with static text.
Take the following example:
Please see the {itemCount, plural,
one {message}
other {messages}
} in your inbox.
In Spanish, the word "the" changes depending on whether or not it's plural. The correct translations in Spanish should be:
one: "Por favor vea el mensaje en su bandeja de entrada"
other: "Por favor vea los mensajes en su bandeja de entrada"
The way to solve this would be to include "the" in the conditional.
Developers are obviously not going to be fluent in every language their app supports. If you don't speak Spanish, you wouldn't know to include "the" in the conditional.
It seems irresponsible to allow this type of syntax. Format.js even promotes using pluralization like this in their examples: https://formatjs.io/docs/core-concepts/icu-syntax/#plural-format
It seems to me that an error should be thrown when attempting to combine static text with dynamic plural text. The entire sentence should be required in the conditional.
My question is: Am I missing something? Should I prohibit my developers from entering values like this?
I can't be the first person that noticed this. Is there a way to enforce this through a setting in Format.js?
Looking at the documentation it looks as though your confusing the {selectordinal} with the message.
By way of an example the Spanish format based on what you have provided would be:
Por favor vea {itemCount, plural,
one {el mensaje}
other {los mensajes}
} en su bandeja de entrada.
Even so that is a relatively simple example as you may also have additional words later in the sentence affected by ordinal number, gender, or both so you may have to have multiple arguments in the sentence.
Declension is quite the fun linguistic topic for developers to get their heads around.
Edit: To add to this, that would give you something like:
const messages = {
en: {
INBOX: 'Please see the {itemCount, plural,
one {message}
other {messages}
} in your inbox.',
},
es: {
INBOX: 'Por favor vea {itemCount, plural,
one {el mensaje}
other {los mensajes}
} en su bandeja de entrada.',
},
}
So for the Spanish it is necessary to move the 'the' into the argument, but not for the English. It is really down to the syntax and the person creating localised messages to utilise that syntax for whatever gendered or ordinal conditions they need to be aware of.

Can I mix markdown code block declaration and latex commands in a custom latex command?

For markdown, with Latex, I wrote a convenient command :
\newcommand{\mauve}[1]{\textcolor{Purple}{#1}}
\newcommand{\fonction}[1]{\begingroup\small\mauve{\texttt{#1}}\endgroup}
\newcommand{\cadreGris}{\renewtcolorbox{quote}{colback=darkgray!5!white,arc=0pt,outer arc=0pt,boxrule=0pt,lowerbox=invisible,code={\tcbset{enlarge left by=0cm}}}}
\newcommand{\code}{\begingroup\cadreGris\footnotesize}
that helps me formatting my source code in markdown that way:
On peut rajouter aux périodes des durées avec \fonction{plusYears(...)}, \fonction{plusMonths(...)}... ou en retrancher avec \fonction{minusDays(...)}...
- la classe \fonction{Duration}...
\code
> ```scala
> import java.time.Duration
> java.time.temporal.ChronoUnit
>
> Duration.of(10192927, ChronoUnit.MILLIS) // PT2H49M52.927S
> ```
\endgroup
Il est possible d'utiliser les méthodes \fonction{toHours()}, \fonction{toDays()}... Mais attention : elles retournent des nombres entiers. Ci-dessus, un `getDays()` renverra 0, car il y a 0 jours... et 2 heures.
Which produces this result I enjoy:
But is there a way I could create a new command, for example \scala,
that would perform:
\code
> ```scala
and then an \endcode that would produce:
> ```
\endgroup
Meaning : is there a way to mix blocks declaration of "markdown kind" and latex commands in a command definition?

Split transpose not considering first character as separator - any alternative?

I have this table:
In each of the cells there is a long list separated by ",":
Rosângela Lima, Ana Carolina Chagas, Sergio Vasquez, Rosana Corrêa, Michele Kida
Analista De Treinamento E …, A procura de nova oportunidade no mercado, Comercial na BRASILMAXI Logística Ltda., Executiva de Vendas e Solucionadora do Grupo BRASILMAXI, Executiva de Vendas na Brasilmaxi Logística LTDA
, achagas#brasilmaxi.com.br, sergio.vasquez#brasilmaxi.com.br, rosana.correa#brasilmaxi.com.br, ,
#ros%C3%A2ngela-lima-4a90a324, #ana-carolina-chagas-24997022, #sergio-vasquez-25a040a4, #rosanacorrea, #michele-kida-83929230
I want it to look like this:
Here is the sample data
I tried to use transpose(split()) however it doesn't work the email line properly:
Google Sheets is not considering the first character as separator.
From "MY TRY" of your shared Spreadsheet, how about modifying the formula at "C15" as follows?
From:
=TRANSPOSE(SPLIT(C3;","))
To:
=TRANSPOSE(SPLIT(C3;",";;FALSE))
About 4th argument, the official document says as follows.
remove_empty_text - [ OPTIONAL - TRUE by default ] - Whether or not to remove empty text messages from the split results. The default behavior is to treat consecutive delimiters as one (if TRUE). If FALSE, empty cells values are added between consecutive delimiters.
Reference:
SPLIT
Added:
In order to retrieve the front space of each row, how about the following modified formulas?
=TRANSPOSE(SPLIT(SUBSTITUTE(C3;" ";"");",";;FALSE))
or
=TRANSPOSE(ARRAYFORMULA(TRIM(SPLIT(C3;",";;FALSE))))

Encoding: 008D character?

Problem: I have a bunch of txt files written in Portuguese on a Windows machine using NotePad. Some of them seem to have been encoded as ANSI. When I open these files using gedit on Ubuntu, some of them contain boxes containing 008D (see screenshot). This is after converting them to UTF-8.
When I print the file contents to the terminal using cat, head or more, this is the output of the same file. Note that everything from última vez up to and including the strange character isn't printed to the terminal.
Olá madrinha! Eu gostava de ir contigo passar férias na montanha, porque acho que vai ser divertido e há muito tempo que já não vou a tua casa e na últimaar a ter saudades. Madrinha, não sei porque és tão simpática comigo mas para mim, és a melhor madrinha do mundo inteiro. Madrinha, ajudas-me sempre que preciso e estás sempre a apoiar-me por isso, quero ir a tua casa para te apoiar a ti. Obrigada madrinha, por me apoiares. Muito obrigado madrinha
When I open the same file using atom.io, everything looks as it should:
Questions: Most pressingly: How can I get rid of this character without opening all files and manually deleting them? And secondly, what is this, i.e., what should I google to solve similar problems?
Found the magical keywords ('remove unicode string using sed'). This does the trick: https://stackoverflow.com/a/8562661/1331521:
# Define unicode character you want to remove;
# In this case 008D:
CHARS=$(python -c 'print u"\u008D".encode("utf8")')
# Then run sed on all files in directory
sed -i 's/['"$CHARS"']//g' *

Dual-line bilingual paragraph in LaTeX [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
An interlinear gloss can be used to layout a translation of a document.
http://en.wikipedia.org/wiki/Interlinear_gloss
Usually this is done word-by-word or morpheme-by-morpheme. However, I would like to do this in a different way, translating entire paragraphs at a time. The following link and image is an example of what I want done, though I want to do it for a different text which is larger.
http://www.optimnem.co.uk/learning/spanish/three-little-pigs.php
For now I am not interested in taking into account the order of words or phrases that change order between languages. That is, I don't mind if the words in the paragraph are not aligned or if the length of one paragraph is much longer than the other, causing an overhanging line.
As far as I can tell, the following packages do not meet my needs:
covingtn.sty
cgloss4e.sty
gb4e.sty
lingmacros.sty - shortex
Here is the english version:
In the heart of the forest lived three little pigs who were brothers. The wolf always was chasing them in order to eat them. In order to escape the wolf, the pigs decided to make a house each. The smallest made his from straw, to finish first and go out to play. The middle one constructed a cottage from wood. Seeing that his little brother had finished already, he hurried to go and play with him. The oldest worked on his house of brick. 'You'll soon see what the wolf does with your houses,' he scolded his brothers but they were having a great time.
Here is the spanish version:
En el corazón del bosque vivían tres cerditos que eran hermanos. El lobo siempre andaba persiguiéndoles para comérselos. Para escapar del lobo, los cerditos decidieron hacerse una casa. El pequeño la hizo de paja, para acabar antes y poder irse a jugar. El mediano construyó una casita de madera. Al ver que su hermano perqueño había terminado ya, se dio prisa para irse a jugar con él. El mayor trabajaba en su casa de ladrillo. - Ya veréis lo que hace el lobo con vuestras casas - riñó a sus hermanos mientras éstos se lo pasaban en grande.
I don't want to do it manually like this:
\documentclass{article}
\usepackage[margin=1in, paperwidth=8.5in, paperheight=11in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{url}
\begin{document}
\noindent
\url{http://www.optimnem.co.uk/learning/spanish/three-little-pigs.php}\\
\\
\indent
En el corazón del bosque vivían tres cerditos que eran hermanos. El lobo siempre\\
\indent
In the heart of the forest lived three little pigs who were brothers. The wolf always\\
\\
%
andaba persiguiéndoles para comérselos. Para escapar del lobo, los cerditos decidieron\\
was chasing them in order to eat them. In order to escape the wolf, the pigs decided to\\
\\
%
hacerse una casa. El pequeño la hizo de paja, para acabar antes y poder irse a jugar.\\
make a house each. The smallest made his from straw, to finish first and go out to play.\\
\\
%
El mediano construyó una casita de madera. Al ver que su hermano perqueño había\\
The middle one constructed a cottage from wood. Seeing that his little brother had\\
\\
%
terminado ya, se dio prisa para irse a jugar con él. El mayor trabajaba en su casa de\\
finished already, he hurried to go and play with him. The oldest worked on his house of\\
\\
%
ladrillo. - Ya veréis lo que hace el lobo con vuestras casas - riñó a sus hermanos\\
brick. 'You'll soon see what the wolf does with your houses,' he scolded his brothers\\
\\
%
mientras éstos se lo pasaban en grande.\\
but they were having a great time.\\
\\
\end{document}\\
I would like to use a package or a macro to automatically have the english and spanish texts interspersed with line breaks when the end of the line has been reached for each. How can I layout this simple dual-line biligual paragraph in Latex in a more automated way (without manually adding line breaks)?
The following hack may help you achieve your goal. It's based on the idea of a zero-height minipage to overlap two triple-spaced minipages.
I'll use placeholders for the English and Spanish text (\english and \spanish respectively). Also, be sure to include the setspace package:
\usepackage{setspace}
\def\english{In the heart of the forest lived three little pigs who were brothers. The wolf always was chasing them in order to eat them. In order to escape the wolf, the pigs decided to make a house each. The smallest made his from straw, to finish first and go out to play. The middle one constructed a cottage from wood. Seeing that his little brother had finished already, he hurried to go and play with him. The oldest worked on his house of brick. 'You'll soon see what the wolf does with your houses,' he scolded his brothers but they were having a great time.}
\def\spanish{En el corazón del bosque vivían tres cerditos que eran hermanos. El lobo siempre andaba persiguiéndoles para comérselos. Para escapar del lobo, los cerditos decidieron hacerse una casa. El pequeño la hizo de paja, para acabar antes y poder irse a jugar. El mediano construyó una casita de madera. Al ver que su hermano perqueño había terminado ya, se dio prisa para irse a jugar con él. El mayor trabajaba en su casa de ladrillo. - Ya veréis lo que hace el lobo con vuestras casas - riñó a sus hermanos mientras éstos se lo pasaban en grande.}
By giving the top block a height of 0pt we allow for the next minipage to overlap it.
\begin{minipage}[t][0pt]{\linewidth}
\setstretch{3}
\english
\end{minipage}
\begin{minipage}[t]{\linewidth}
\setstretch{3}
\spanish
\end{minipage}
The primary One of the problems with this idea is that if the zero-height section is longer than the regular section, then you'll have some lingering overlapping text to deal with. (Edit: This problem is addressed in the comment below, note that line-breaks will also be a serious drawback to this idea.)
The result (in part):
I don't think there is a package to do what you want, but it is possible to implement this yourself using \vsplit, which is well documented in Tex by Topic (availble for free download, or in the dead-tree edition via Lulu). The basic idea is
You define two vboxes, one for the English, one for the Spanish, and you want to take out the contents one line at a time. Call these vboxes \ENbox and \ESbox;
You need to determine the correct vertical dimension to use: this might be \lineheight, or you might need a different value, you will have to experiment. Assuming \lineheight is right ...
... then you can get the next line of English using \setbox\nextline=\vsplit\ENbox to \lineheight, which you can output using \unvbox\ENbox, then likewise the next line from \ESbox, then some vertical space for the intergloss gap;
Then you need to test the loop, which you can do by querying the vertical heights, using \ht, of \ENbox and \ESbox. This bit will be fiddly.
All-in-all, this will be somewhat tricky coding: good luck, and don't hesitate to ask questions here if you run into difficulties.
Postscript This is obviously much more work than Geoff's much simpler solution, which for some reason I hadn't seen when I wrote this, but it should be more flexible if you want to fiddle with it.
If you want to interlace Spanish and English paragraphs, and have them line up approximately correctly, then what you want is to write your translations word-by-word (or several words by several words), and use a gloss package that can wrap long sentences. I've done this before using gloss.sty. An example of its use(the goal was to gloss each word with its part of speech):
\gloss Both knowledge and wisdom extend man's reach. Knowledge led to
cjc nn0 cjc nn0 vvb {nn0 pos} {nn0 pun} nn0 vvd prp
\gloss computers, wisdom to chopsticks. Unfortunately our association is
{nn2 pun} nn0 prp {nn2 pun} av0 dps nn1 vbz
\gloss overinvolved with the former. The latter will have to wait for a
ad0 prp at0 {nn0 pun} at0 nn0 vm0 vhb to0 vvb avp at0
\gloss more sublime day.
av0 aj0 {nn1 pun}
\unhbox\gline
The package lines things up words from the first language with words from the second "language" using spaces. To line up multiple words in one language with a single word (or multiple words) from the other language, use braces to group the multiple words. Though the lines here are interlaced, this is just for my editing convenence. You could write really long lines if you wanted to, and the gloss algorithm will wrap them properly.
I've also used a two-column paragraph-by-paragraph approach using the parallel package.
put an extra line break in between each set of lines:
%
andaba persiguiéndoles para comérselos. Para escapar del lobo, los cerditos decidieron
was chasing them in order to eat them. In order to escape the wolf, the pigs decided to
%

Resources