how to generate output json file with i18next with CLI? - i18next

I am new to i18next parser. I followed https://github.com/i18next/i18next-parser instruction with CLI.
By running i18next 'app//.{js,hbs}' 'lib//.{js,hbs}' [-oc] it parse all my JS files from app directory, but It never generate any json file.
I have output: 'locales/$LOCALE/$NAMESPACE.json' on my i18next-parser.config.js file.
Any help would be appreciated.

You need to specify the output argument.
i18next 'app/**/*.{js,hbs}' 'lib/**/*.{js,hbs}' -o=locales/$LOCALE/$NAMESPACE.json

Related

Vue.js - want to lazy load config.json, instead of including at compile time

I'm trying to create a file like the appsettings in a web.config in my vue app, that my vue app can use to load config info at runtime that changes form one deployment level to another (dev/qa/prod)
I'm loading it thusly
Vue.prototype.$config = require('/public/config.json')
but when I look at the transpiled output, it has the values of the file loaded in and hardcoded, not code to load from the file
in app90117256.js: (and js.map)
t.exports = JSON.parse('{""name":"value" etc.....
How do I get it to load the file at runtime instead.
If you want to load the config at runtime, do not use build time constructs, which require or import (or Vue CLI ENV variables) are...
Options:
use either XHR or fetch browser API to request the json file from the server during (or before) your app starts
transform the json into JS file which assigns some global variable (window.appConfig for example), load it using <script> placed in index.html (before your app bundle) and then access it using window.appConfig from the app

How to run ui testing?

I get an error when I start testing the application:
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
...
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
/home/mmvs/Desktop/ReactNative/node_modules/react-navigation/src/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export * from '#react-navigation/core';
How to solve this error?
You need to add moduleNameMapper in package.json
look at this link : https://jestjs.io/docs/en/webpack#handling-static-assets

Read yaml file with vue.js from disk (not URL)

In Vue.js I would like to read a YAML file from my filesystem (this file is not available online so can not be requested via URL), convert it to JSON and somehow expose it in a way that all components can access it. How can I do it?
I should probably use js-yaml but I can't find a way for it to work in Vue.js.
I may be missing the problem, but
npm install yaml-js --save
then import into component and use
<script>
import { yaml } from 'yaml-js'
// or maybe the following, try both
import yaml from 'yaml-js'
Your biggest problem would be the location of the Yaml file to be read in. I'm reading files from the static folder, so if you can locate it there you should be able to read it with
return Vue.http.get('Yaml.whatever')
.then(response => {
// process response.body
In main.js set up the root path (must be within your web site)
import VueResource from 'vue-resource'
Vue.use(VueResource)
Vue.http.options.root = './static/'

What is the format of logstash config file

Does logstash use its own file syntax in config file? Is there any parser or validator for config file syntax?
For anyone that does not use logstash but have idea about file formats here is a sample syntax:
input {
file {
path => "/var/log/messages"
type => "syslog"
}
file {
path => "/var/log/apache/access.log"
type => "apache"
}
}
The Logstash configuration file is a custom format developed by the Logstash folks using Treetop.
The grammar itself is described in the source file grammar.treetop and compiled using Treetop into the custom grammar.rb parser.
That parser is then used by the pipeline.rb file in order to set up the pipeline from the Logstash configuration.
If you're not that much into Ruby, there's another interesting project called node-logstash which provides a Logstash implementation in Node.js. The configuration format is exactly the same as with the official Logstash, though the parser is obviously a different one written for Node.js. In this project, the Logstash configuration file grammar is described in jison and the parser is also automatically generated, but could be used by any Node.js module simply by requiring that generated parser.
You can use the following command to verify your logstash config file is valid:
bin/logstash --configtest --config <your config file>
Apparently command line arguments have been updated since the answers have been posted and --configtest and --config arguments are no longer valid. In order to ask Logstash (at least v5) to validate config file:
bin/logstash -t -f config.conf
With expanded arguments it looks like this:
bin/logstash --config.test_and_exit --path.config config.conf
So far. there is no any parser or validator for logstash config. You can only use the logstash to verify the config.
For more information about config, you can visit here. All the format is introduced in this page.
The Logstash-Config Go package config provides a ready to use parser and Abstract Syntax Tree for Logstash configuration files in Go.
The basis of the grammar for the parsing of the Logstash configuration format is the original Logstash Treetop grammar .
logstash-config uses pigeon to generate the parser from the PEG (parser expression grammar).

Rails i18n using java .properties files

Is it possible to use java .properties files in a Rails project instead of YAML files? And if so, how do you set this up?
generally the i18n integration works with YAML files or plain ruby hashes. So you could simply parse the .properties files (I think https://github.com/flergl/java-properties-for-ruby would still do the job, works even still with 1.9.3 at first glance) and convert them to YAML or dynamically parse them in something like:
# config/locales/en.rb:
# Gemfile: gem 'java_properties'
# or require 'rubygems'; require 'java_properties';
props = JavaProperties::Properties.new("de.properties")
translations_hash = props.keys.inject({}) { |hash, key| hash[key] = props[key]; hash }
{ :en => translations_hash }
Of course you might still need to replace placeholder syntax "{0}" to a i18n compatible "#{0}".
Cheers,
Fred
ps.: BTW check out our service PhraseApp.com we are working on easing the i18n pain!