Upload Angular-locale dynamically - angularjs

I use the i18n/angular-locale to manage the data.
In my html page I have a dropdown with the language, when I change the language I would like to upload the correct i18n/angular-locale (for example if I select France to upload i18n/angular-locale_fr.js...) there is a dynamically mode to load
this file instead of to upload all files

I hope to have understood your question: there's a nice AngularJS module called angular-translate that let you easily manage all the i18n stuff.

Related

Interactive SVG in Angular Js?

I want to implement interactive svg in Angular Js application. Here is a glimpse of Svg which I will be using. I Know how to use an Svg in angular but the purpose of this question is not this. I want to make it dynamic. Like when I click "Punjab", the svg zooms in and show me regions, and upon clicking a specific region , it shows me the data which i will be getting through backend. So I am just curious, is this even possible ?
Based on your requirement you can use google map which can be easily integrated with Angular. Also I suggest to check D3.js.
Its Javascript library for creating SVG dynamically and can be easily integrated via Angular directives. There are plenty of examples available for the same.

How to handle python i18n translations with react

I'm looking into bringing React into my codebase(pyramid, jinja2). It almost looks like a good fit. I'm just confused as to how to handle translations from python. I'm using the pyramid.i18n library and I would normally just have _() function in context that translates strings like {{_('Hello')}} to "Hola" and whatnot. If I moved to React my markup would now be in JS. And I don't want to have Jinja render my JS so it remains static. Is there a good way to handle this?
Ended up using https://github.com/webpack/i18n-webpack-plugin and serving up the specific bundle file based on a saved language setting.
So on the backend we store in the database which language a user wants to use. We have json files of translations for all the languages & words we support. When compiling the bundle files with this plugin we get a bundle for each language that uses those json files to swap out the translated words. So something like bundle.en.js for english and bundle.es.js for spanish. When a user requests a page we serve up the bundle file associated with their selected language stored in the DB.

how to render multiple languages in AngularJS webpage?

I am new to AngularJS, I've a requirement where I should display the products of different countries in a single webpage with different languages(localized language of that countries). Response is coming in the single JSON file for all the countries.
I've tried to use Angular Translate but I was not successful. Could anyone suggest if there is any better way to do?
I use Angular Translate with Multi-language support and it's working fine,
You can check this link
Did you tried https://angular-gettext.rocketeer.be/ ?
we have implemented it by creating different js as per language

AngularJS export html to pdf with css

I have a task where I need to export the html to pdf. Where the pdf should have the same design as it has in browser. Basically I need the css should also work in pdf file. Am using angularjs for front end. But I have not found any use full module or any js library which supports my requirement. I also need to update AngularJS scope variables values in pdf. I found one http://pdfmake.org/#/ but it only supports some predefined css attributes. Please provide some suggestion if there is some npm module or any js library which render the html to pdf with css.
Thank you
I am not sure if there is a fully featured JavaScript solution, which can convert HTML/CSS to PDF on client side. It makes sense to take a look to server-side solutions - there are many available.
In an "hybrid" scenario on client side you'd need to populate a HTML/CSS template with variable values, send the resulting HTML/CSS doc to the server side and to receive back a generated PDF.
In the case it is not important anymore, if the converter is written in JavaScript. You may use a standalone native applications, utilize print/PDF output subsystem of WebKit (i.e. PhantomJS) or it can be, for example, a Java module deployed to your application server (i.e. PD4ML).

use one large external file for many javascript templates with backbone.js?

I have two different HTML pages that serve up backbone apps. Up until now, I have put all the js templates inside of each respective HTML file.
Now, I'm refactoring a bit and would like to share some backbone views between files. When loading a view that can't find a js template, the whole app will error out. I know the proper way to merge these two would be to have external js templates, using EJS for example, and have 1 template per file, however, I'd like to just have one huge HTML file with embedded <script type='text/template'> and share the template HTML file between my 2 pages. Is this possible? I tried getting the external js templates with AJAX and writing them to the head, but backbone views still can't find them.
Does anyone else choose to have a file with many javascript templates in it? I also find that I have an unmanageable number of files open when I use ejs. Any help would be most appreciated.
I use an extra javascript/coffeescript file and use underscore's templating to take care of everything. This way you can include the templates and put them into as few (or many) files as you would like.
I'm using a single file for all the templates on my current project and it is working out pretty well.
It's a Asp.Net site, so I made the template file into a user control so I can easily include it in any page that uses Backbone.
If you're fetching all templates through AJAX, maybe you don't have to write them to the head.
You can send templates to the client as JSON Object, for example:
{"about":"<p>About</p>...","gallery":"<p>Gallery</p>...","contact":"<p>Contact</p>..."}
After fetching temples you can store them as templates variable inside some object(or locale storage), and after that you can do the following:
var tempStr = templates['about'],
template = new EJS({element:{value: tempStr, id: 'about'}}),
content = template.render();

Resources