How include properties file for internalisation? - node.js

I am working on a node JS project with the Kraken framework. Then I use Dust templating and makara for the internationalization. But actually, I have one .properties file for each .dust file and i would like include a main.properties for each other properties for sharing same content across the pages.
I try this in a properties :
include = main.properties
But it doesn't works.
Do you have an idea ?
Thanks you in advance.

There is no mechanism for include currently. This issue is the one to track on that matter: https://github.com/paypal/makara/issues/11

Related

How to use and access the preference in thunderbird , in Webextension environment ,not in the legacy

Currently using this method as a legacy method.
this.prefService = Components
.classes["#mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
this.prefBranch = this.prefService.getBranch(root);
but i did not get a complete idea about how to use this in the webextension environment thunderbird .any api in order to use this feature ?
I solved my issue, by using Web Extension experiment.
Implemented the same legacy extension function with the Web Extension Experiment Specification and that solved my need at this moment.
the link mentioned below.
https://thunderbird-webextensions.readthedocs.io/en/68/how-to/experiments.html
https://firefox-source-docs.mozilla.org/toolkit/components/extensions/webextensions/functions.html
I think you can use the storage.local API (see documentation, it seems to work the same for Firefox and Thunderbird). This allows you to store data related to your add-on with something like:
let settingItem = browser.storage.local.set(
keys // object
)
and to retrieve or remove it after that (see available methods).

React Native has something to use local folders as 'package name'. What is it called?

It's kind a strange question, but you can probably help me!
In React Native you can add a package.json file to your config folder for example with the content:
{
"name": "#config"
}
Later on, everywhere in your project (no matter how many folders deep), you can load any config-file using import http from '#config'.
Can anybody tell me how this is done, and how this is done? I really want to do this in my own Node.js project :)
Thanks in advance!
Bob
If you plan to publish your package, the most important things in your
package.json are the name and version fields as they will be required.
When you create a new package.json and named it as {"name": "#assets"}, Now you are exposing your image dictionary assets as a module. So your question is answered -how this is done? And for accessing do this import Images from ‘#assets/images’; in components. Read more here

How should I load a file that is inside my own module?

Current code in /config/index.js
const options = (require('js-yaml')).safeLoad(
(require('fs')).readFileSync(`./config/default-config.yaml`, "utf8"));
module.exports = options;
Works fine. Until I publish and use it in my other project. Then it's unable to find the file (naturally) as ./config/default-config.yaml doesn't exist in that project.
The only option I can think of involves checking to see if the file exists at that path, then trying to load it from node_modules/#company/alpha-gamma/config/default-config.yaml. This seems really hacky.
The config object is large, 200+ keys. I don't think it belongs in the code.
What's the best solution for loading a file that exists inside your module? I need to be able to load it for unit tests before publishing and load it at runtime when the library is required by another module.
Maybe the best alternative is to use json since I can then use the require module to load it in, instead of fs.
While I originally suggested utilizing __dirname as a valid option, I was wrong. Calling process.cwd() to fetch the application root and building the path off of that is the best approach.
As documented here:
Proper way to reference files relative to application root in Node.JS

Setup a Typescript project with classes shared between client and server apps?

I currently have a solution with two projects. ServerApp (nodejs NTVS) and BrowserApp (Html Typescript application).
I wish to share classes between both projects and get immediate intellisense.
How to do that ?
PS: for those how know GWT, what I want is similar to the shared project.
I managed to do it this way :
create a third project named SharedClasses (I used HTML Typescript template)
add my shared classes in it
add a shared_reference.ts file with references to those classes files
add a link to the reference.ts file in ServerApp and BrowserApp projects that point to shared_reference.ts
/// <reference path="../SharedClasses/shared_reference.ts" />
Autocompletion works, F12 too...
If you use an external build tool e.g grunt-ts its easier. For a demo check out : https://github.com/basarat/demo-fullstack
With a sample gruntfile (https://github.com/basarat/demo-fullstack/blob/master/src/Gruntfile.js). Important bit:
var commonFiles = "common/**/*.ts";
var serverFiles = ["server/**/*.ts", commonFiles];
var clientFiles = ["client/**/*.ts", commonFiles];

What is the best way to develop *.js with ServiceStack self-host?

Due "Copy to Output" for js files it is impossible to just edit js file and reload the page to see the changes. It is required to restart the service.
One of the possible solutions is to modify VFS to look at js files in the correct location (solution tree, not in the output folder) in DEBUG mode.
Any other suggestions?
Thanks,
Dmitry
The simplest solution is
SetConfig(new HostConfig
{
WebHostPhysicalPath = "C:\\projects\\path_to_self_host_project"
});

Resources