Play! Framework 2.0.3, i18n error, `=' expected but `-' found - java

I'm new in "Play! Framework" and I'm trying to do a i18n for pt-BR.
My message file is called 'Message.pt-BR' and i put the pt-BR lang in application.conf.
In Java I'm using something like this:
flash("success", Messages.get("logout.success"));
And in scala.html files I'm using this:
#Messages("logout")
In my Message.pt-BR file I've this:
logout=Sair
logout.success=Logout realizado com sucesso. Volte sempre!
When I compile the project I have no errors, but when I request some page a have this error:
`=' expected but `-' found
Messages.pt-BR
Someone can help me?

I think you have to rename your message file from Messages.pt-BR to Messages.pt_BR (with a lower '_').

Related

How to set JsonTemplateLayout eventTemplateUri outside of classpath in Log4j2

In Log4j2's JsonTemplateLayout, I have no problem using eventTemplateUri: "classpath:LayoutTemplate.jsson" with json file located in rc/main/resources.
However, I would need to keep this file outside of class path. so I would like to use file location something like he way we add log fileName: c:\...
But it's throwing an error when I use eventTemplateUri: "C:\ ....\LayoutTemplate.json"
rror message is " Could not create plugin of type class org.apache.logging.log4j.layout.template.json.JsonTemplateLa
yout for element JsonTemplateLayout: java.lang.RuntimeException: failed reading URI: C:...
Did I miss anything here?
is it possible to place this json file outside of class path?
Thanks!
All *Uri configuration knobs in JsonTemplateLayout expect a URI string. In your case, the URI scheme is missing. The eventTemplateUri should look like file:///C:/path/to/LayoutTemplate.json in your case. For internals, see how o.a.l.l.l.template.json.util.Uris.readUri(String,Charset) is implemented.

apache PIG with datafu: Cannot resolve UDF's

I'm trying the quickstart from here: http://datafu.incubator.apache.org/docs/datafu/getting-started.html
I tried nearly everything, but I'm sure it must be my fault somewhere. I tried already:
exporting PIG_HOME, CLASSPATH, PIG_CLASSPATH
starting pig with -cpdatafu-pig-incubating-1.3.0.jar
registering datafu-pig-incubating-1.3.0.jar locally and in hdfs => both succesful (at least no error shown)
nothing helped
Trying this on pig:
register datafu-pig-incubating-1.3.0.jar
DEFINE Median datafu.pig.stats.StreamingMedian();
data = load '/user/hduser/numbers.txt' using PigStorage() as (val:int);
data2 = FOREACH (GROUP data ALL) GENERATE Median(data);
or directly
data2 = FOREACH (GROUP data ALL) GENERATE datafu.pig.stats.StreamingMedian(data);
I get this name-resolve error:
2016-06-04 17:22:22,734 [main] ERROR org.apache.pig.tools.grunt.Grunt
- ERROR 1070: Could not resolve datafu.pig.stats.StreamingMedian using imports: [, java.lang., org.apache.pig.builtin.,
org.apache.pig.impl.builtin.] Details at logfile:
/home/hadoop/pig_1465053680252.log
When I look into the datafu-pig-incubating-1.3.0.jar it looks OK, everything in place. I also tried some Bag functions, same error then.
I think it's kind of a noob-error which I just don't see (as I did not find particular answers for datafu in SO or google), so thanks in advance for shedding some light on this.
Pig script is proper, the only thing that could break is that while registering datafu there were some class dependencies that coudn't been met.
Try to run locally (pig -x local) and see a detailed log.
Check also the version of pig - it should be newer than 0.14.0.

Using Voce speech recognition in Java

I've been trying to get speech recognition to work on a Java application, I've tried Sphinx but it's too complex for what I need, so I found Voce.
I'm trying to get the recognition demo to work.
The problem is I can't initialize the SpeechInterface, here's the code I've been using:
voce.SpeechInterface.init("C:/Users/G/Documents/NetBeansProjects/VoceTest/lib",
false,
true,
"C:/Users/G/Documents/NetBeansProjects/VoceTest/lib/gram",
"digits");
I have a grammar file named digits.gram in the gram folder inside the lib folder.
As a result I get:
[Voce ERROR] Cannot configure speech recognizer:
Property Exception component:'jsgfGrammar' property:'grammarLocation' - value (C:/Users/G/Documents/NetBeansProjects/VoceTest/lib/gram) is not a valid Resource
at edu.cmu.sphinx.util.props.ValidatingPropertySheet.setRaw(ValidatingPropertySheet.java:137)
at edu.cmu.sphinx.util.props.ConfigurationManager.setProperty(ConfigurationManager.java:250)
at voce.SpeechRecognizer.<init>(SpeechRecognizer.java:85)
at voce.SpeechInterface.init(SpeechInterface.java:79)
at vocetest.VoceTest.main(VoceTest.java:18)
I read the docs but I can't figure out what I'm doing wrong
"file:/C:/Users/G/Documents/NetBeansProjects/VoceTest/lib/gram","digits");"
The above line should work without errors.

Route to upload file in Play Framework 2.10

I upload files to /upload folder, then I want to directly access my files, like:
http://localhost/upload/xxx.jpg
when I add routes as below:
GET /upload/*file controllers.Assets.at(path="/upload", file)
It causes another error:
not enough arguments for method at: (path: String, file: String)play.api.mvc.Call. Unspecified value parameter file.
<link rel="stylesheet" media="screen" href="#routes.Assets.at("stylesheets/main.css")">
Then, after I change #routes.Assets.at("stylesheets/main.css") to #routes.Assets.at("stylesheets/", "main.css"), there is another error:
[MatchError: (stylesheets/,main.css) (of class scala.Tuple2)]
(path: #unchecked, file: #unchecked) match {
Can somebody help me with this route? Thanks.
finnal, I got answer from playframework website, it not very obvious to find..
http://www.playframework.com/documentation/2.0.4/Assets
from this page:
However, if you define two mappings for the Assets.at action, like this:
GET /javascripts/*file controllers.Assets.at(path="/public/javascripts", file)
GET /images/*file controllers.Assets.at(path="/public/images", file)
Then you will need to specify both parameters when using the reverse router:
<script src="#routes.Assets.at("/public/javascripts", "jquery.js")"></script>
<image src="#routes.Assets.at("/public/images", "logo.png")">
but this may not solve my problem yet, it turn out to appear the second error mention in the question.
Be Careful, check the path param, it must be the same as you described in routes file. as:
when I set:
GET /public/*file controllers.Assets.at(path="/public", file)
in the html file, I should write as below:
#routes.Assets.at("/public", "stylesheets/main.css")
besides, if you use another folders, like /upload, adding below code in project/Build.scala in play.Project is essential. thanks TizianoPiccardi
playAssetsDirectories <+= baseDirectory / "foo"
You should add this line in project/Build.scala:
val main = play.Project(appName, appVersion, appDependencies).settings(
// Add your own project settings here
playAssetsDirectories <+= baseDirectory / "upload"
)
More info:
https://github.com/playframework/Play20/wiki/Assets

Creating index and adding mapping in Elasticsearch with java api gives missing analyzer errors

Code is in Scala. It is extremely similar to Java code.
Code that our map indexer uses to create index: https://gist.github.com/a16e5946b67c6d12b2b8
Utilities that the above code uses to create index and mapping: https://gist.github.com/4f88033204cd761abec0
Errors that java gives: https://gist.github.com/d6c835233e2b606a7074
Response of http://elasticsearch.domain/maps/_settings after running code and getting errors: https://gist.github.com/06ca7112ce1b01de3944
JSON FILES:
https://gist.github.com/bbab15d699137f04ad87
https://gist.github.com/73222e300be9fffd6380
Attached are the json files i'm loading in. I have confirmed that it is loading the right json files and properly outputting it as a string into .loadFromSource and .setSource.
Any ideas why it can't find the analyzers even though they are in _settings? If I run these json files via curl they work fine and properly setup the mapping.
The code I was using to create the index (found here: Define custom ElasticSearch Analyzer using Java API) was creating settings in the index like:
"index.settings.analysis.filter.my_snow.type: "stemmer","
It had settings in the setting path.
I changed my indexing code to the following to fix this:
def createIndex(client: Client, indexName: String, indexFile: String) {
//Create index
client.admin().indices().prepareCreate(indexName)
.setSource(Utils.loadFileAsString(indexFile))
.execute()
.actionGet()
}

Categories

Resources