Vue i18n object syntax with parameter inside quotation marks - vue.js

I'm using Vuei18n, and, reading from https://kazupon.github.io/vue-i18n/guide/formatting.html#list-formatting, I discovered I could use the object syntax. What I would like to achieve is to get a translation with a parameter that will be inserted dinamically:
"object": {
"ciao '{0}'": "HALLO '{0}'"
}
Usage: i18n.global.t('object.' + "ciao '{0}'", param)
Expectation: "ciao 'Bob'"
Result: it doesn't translate at all.
The problem is in those single quotation marks, if I would remove them, it would work.
So how could I keep the single quotation marks?

Related

Reference value of constant with KDoc

I have a object like the following in my project
object UrlUtils {
private const val PARAM = "whatever"
/**
* Method that appends the [PARAM] parameter to the url
*/
fun appendParameter(url: String) {
// ...
}
}
As you can see a I wanna reference the value of the PARAM field in the KDoc comment of the appendParameter method however when looking at the comment I don't see the actual value but only the name of the field.
Method that appends the PARAM parameter to the url
What I want:
Method that appends the whatever parameter to the url
In Javadoc this works by using {#value PARAM} but there seems to be nothing similar in KDoc. Even the automatic code-converter keeps the old Javadoc.
So my question: Am I missing something or is KDoc/Dokka missing this feature?
Currently, {#value} tags are not supported by KDoc.
The closest issue requesting this is #488, so you can up-vote and/or comment on it.

How to use for inside IntelliJ Live Template?

I am trying to write a simple Groovy script which concatenates strings.
This Groovy script is intended to be used as a variable inside an IntelliJ Live Template and generate some code.
When I set the $variableResolvedWithGroovyScript$ to have the following value:
groovyScript("def elements=[\"firstElem\",\"secondElem\",\"thirdElem\"];
String result=\"\";
for (String element : elements) {
result=result+element;
}
return result;"
, clipboard())
I get below error:
startup failed:
Script1.groovy: 1: expecting EOF, found 'return' # line 1, column 183.
lt+element; } return res
^
1 error
However, if I try and remove the for braces({ and }) it works without any problems:
groovyScript("def elements=[\"firstElem\",\"secondElem\",\"thirdElem\"];
String result=\"\";
for (String element : elements)
result=result+element;
return result;"
, clipboard())
If I take above script and run it inside a Groovy Console it works without problems, so I assume this is a Live Template issue.
I tried to escape the braces in the same way the quotation marks are escaped, but without any luck.
How can I write a for(containing more than one instruction) inside of a Live Template ?
I managed to make it work by loading the Groovy script from the disk. So instead of the $variableResolvedWithGroovyScript$'s value, which was:
groovyScript("def elements=[\"firstElem\",\"secondElem\",\"thirdElem\"];
String result=\"\";
for (String element : elements) {
result=result+element;
}
return result;"
, clipboard())
I simply used:
groovyScript("d:\\Some\\Path\\Concatenate.groovy" , clipboard())
The d:\Some\Path\Concatenate.groovy worked with braces and I was also able to define new methods and so on.

Vue - removing all spaces from a string from Firestore database

I am still learning Vue. I know how to remove all spaces from a string using Javascript, such as:
var str = " a b c d e f g ";
var newStr = str.replace(/\s+/g, '');
I can't figure out how to implement this in Vue.
I would like to take a string from my Firestore database, say a field called "title1", with a value of "This is my string" and remove all spaces so it says "Thisismystring". Then I want to be able to use that string in my Vue app in the same way I would use title1... like a variable called title1nospaces.
I'm not sure if I should be using a computed property or a method. Anything I've tried always comes back as "title1nospaces" is not defined on the instance but is referenced during render".
Any help appreciated.
var str = " This is a test ";
var new_str = str.split(' ').join('');
console.log(new_str); // 'Thisisatest'
In your vue app, you should add a mixin and in that mixin you should implement a method that takes an input with spaces and it should return the output as a string without a spaces (or formatted string).
E.g.
let myApp = new Vue({
mixins: [CommonUtils],
});
CommonUtils.js code ( I am using ES6 syntax):
export default {
methods: {
myStringFormattingFun(input) {
// Do your magic and return the formatted string
}
}
}
OR you can just implement the function in your myApp component (main component).

Hive : accented characters to their non accented counterparts

How can I replace non-ascii characters with their ascii counterparts in a SELECT request sent to hive ? That is have accents removed (é, ê, è => e) and have other non alphanumeric characters (``) removed.
I know I can use regexp_replace() but I'd have to deal with every accented/non-accented pair there is. Surely, there is something more practical ?
It seems that you want to use
String subjectString = "öäü";
subjectString = Normalizer.normalize(subjectString, Normalizer.Form.NFD);
As described in
Replace non ASCII character from string
I have tried using reflect but couldn't make it work due to the Normalizer.Form enum parameter.
So, it seems that you have to define a one-line UDF:
public class NormalizerUDF extends UDF {
public String evaluate(String in) {
return Normalizer.normalize(in, Normalizer.Form.NFD);
}
}

How to use MEL in dataweave to replace characters in a string

I am using Anypoint Studio 6.1 and Mule 3.8.1 and have this MEL expression that replaces any text \n with a new line/carriage return.
payload.replace('\\n', System.getProperty('line.separator'))
I would like to move this functionality into Dataweave but cannot get the MEL expression to work or find a way to do this in Dataweave.
How can I reuse the MEL expression in Dataweave?
Thanks
You should investigate Global Functions
Like:
<configuration doc:name="Global MEL-Functions">
<expression-language>
<global-functions file="mel/extraFunctions.mvel">
</global-functions>
</expression-language>
</configuration>
And create your the global function in a resoruce file for reuse
def UUID() {
return java.util.UUID.randomUUID().toString();
}
def decode(value) {
return java.util.Base64.getDecoder().decode(value);
}
def encode(value) {
return java.util.Base64.getEncoder().encodeToString(value.getBytes());
}
def stringToAscii(value) {
StringBuilder sb = new StringBuilder();
for (char c : value.toCharArray())sb.append((int)c);
return new BigInteger(sb.toString());
}
And reference your global functions in your dataweave
payload map
{
target: stringToAscii($) as :string
}
DW is its own mini-language within Mule aside from MEL is how it was described to me and uses a different syntax to do what you are trying. I have not done new lines specifically as my DW expressions use line separators as record separators, but the same general tactic should work. Here is an example of changing commas to spaces within a dw payload mapping:
AcctID: $.ACCOUNT_ID replace "," with " ",