How to internationalize html pages - html

Is there a way to internationalization html pages based on user locale?
I had a website developed using html pages but now I am asked to internationalize that website in 4 different languages.
I know how to do it using Spring Framework via resource bundles but I wanted to know if there is a way to do something similar using HTML pages so that you just have to write the code considering internationalization and just keep adding the resource bundles to be picked based on user locale when a user accesses the website?

I've just developed a solution a little bit lighter, using CSS content property :
https://github.com/k-yak/stati18n
Take a look, all informations are available in the readme file.

How about this?
http://code.google.com/p/jquery-i18n-properties/

Or How about this?
How does internationalization work in JavaScript?
If you can't do Javascript you'll have to use some form of templating or dispatching. That is either respectively:
Use JSP and Spring's Message taglib (or any other templating language that supports i18n)
For each locale you would copy all the HTML pages in a locale directory and then dispatch to the directory based on the locale (I don't recommend this).
What I personally do is use jMustache which is barely a templating language and then for each page (or many pages) I will have request controller that will load all the translations for the request locale into a Map object which I feed to jMustache (see Option 2 of my answer here: https://stackoverflow.com/a/10004113/318174).

If you keep your site static, you'll end up having multiple copies of your site, unless you can dynamically modify the page using javascript. But, you'll also want the URL's to have the language code in them to save state and be good for SEO.
I developed this free solution. http://www.sitetran.com/

Related

Available Options for HTML Static File Templating

What are the most common options for templating HTML files for static pages, to minimize maintenance and redundancy? An example of my question would be Adobe Dreamweaver.
Consider using a server-side scripting language such as PHP or ASP.NET. These produce dynamically built web-pages meaning that you can code it in such a way that headers/footers etc are separate from the main content, meaning you change that link once rather than 30 times.
If server-side scripting is not an option, I'd suggest having a look at Dreamweaver. This will enable you to create templates, and then create pages based on those templates. When you modify that link in the template, all pages that use that template will be updated. This will give you what you want without the server-side scripting.
why dont you use iframe inside ? ( which will contain a single navigation html page...)?
If you're using a server-side language like PHP, you can start to use the include function. So you'll include in a different file your navigation bar and then include it in every file of your website. Thus, every change to the navigation bar file will affect all the others files.
If you are writing only static pages, it isn't possible. Maybe you can try SSI.
Typically you need either a fancy program (like Dreamweaver and its templates functionality) or some sort of server-side scripting. Languages like php, asp, etc might be a bit much if the only thing you are looking to do is as you describe, so I might look into seeing if your server support server side includes (SSI).

Automatic translation for HTML files

I want translate a web page for multiple languages. I can create a .html file for each language, but I would like only one .html file and use an automatic way for translations.
Is it be possible?
It is not possible for a static website. I suggest you stick to having separate files for each locale.
The easiest way for you to achieve that (since you are obviously the beginner) would be to actually use PHP and generate appropriate language web page on the fly.
Alternatively (but I must warn you that this approach may result in very unresponsive web page) you can use JavaScript to translate your web page - in fact jQuery plus Globalize. However, this force you to use common anti-pattern, that is you would need to force users to choose their language as oppose to automatically infer it from web browser's settings.
Either way, you have a lot of things to learn...

Using iframes in the place of proper 'master pages'

I've been told I have to make a 100% HTML CSS Javascript site for a project at school. I'm used to the master pages of asp.net and I'm worried about how I'm going to do a huge website without the use of them.
After thinking about it for a while, I came up with what I think is an ok solution. Using iframes...
Would it be safe to make one page that has an iframe instead of a content area to connect to other pages to make it appear as if we used a master page?
It seems kind of hacked up so, is there a better way? Is there any software (hopefully free) that provides a decent system of master pages?
Thanks!
You could use a js-based template engine, such as jQuery templates.
You could just dreamweaver and use dreamweaver templates.
Template-Toolkit includes the ttree utility, which will do what you want. You can build the site from templates to get plain, static HTML documents. Since this takes place at build time, you do not need anything like ASP / PHP / Perl / etc on the server at runtime.

How do I create some HTML help pages, with the same content at the top and bottom, without php or ASP etc?

I want to create some html help pages, separate html pages.
However, I want to have the same content on the top and bottom of the pages.
In the past I've used PHP or ASP, with header and footer files.
I've then had to do view source and save these pages to get what I want.
I just wondered if there an easiest way to do this ?
EDIT:
The pages are for use with software using a web object not a normal browser. So there won't be a web server
If your web server supports it, you could do server side includes
You could use frames, but it's not necessarily advisable (for one, it breaks navigation).
You could use XML files with an XSLT stylesheet to turn them into HTML documents that share similar elements.
You could use PHP or another server-side language to generate the pages, and then use a recursive download tool (such as wget) to turn them into HTML.
EDIT: you're basically asking whether the "standard-ish" subset of HTML supported by your component of choice provides a way of including data from a common file, just so you won't have to include the data in every HTML document.
The answer hovers somewhere between "no way" and "maybe your component has a few tricks to do that".
The sane thing to do here would be to have a tool generate the HTML documents from a common template. Could be XML + XSLT, PHP/ASP/whatever, or a fully-fledged CMS (this actually helps let non-technical users write the document contents).
It's awful, but you could include a JS file that uses a bunch of document.write("...") to include common elements. Not SEO friendly.

Best way to use the same HTML on static web-pages

If you use dynamic pages like JSP or asp.net, you can have your page template included, and then content added. But what if you have no server-side component and all pages are just HTML/JS? You can of course create a template then copy it for each page, but then if you want to change something you risk having to modify every page, even if you put most styling in CSS properly.
Are there any non-awful ways to do this? I could see that an iframe could be used to load the content into the central page but that sounds nasty. Does HTML provide any way to include a base file and add to it?
You can use Server Side Includes to include other files on the server. It's similar to scripting languages like ASP or php, but SSI is usually supported by the server directly, so it's available on many servers, even if there is scripting language available.
The answer is still templates. Just process them offline instead of on the server. I like to use ttree for this.
You can create the pages offline and render into HTML, and deploy those to the site.
One option might be: https://github.com/thewml but it does feel ... "too much". I also saw asciidoc for creating sites ( https://asciidoc.org/ ) and I also used several times doxygen for that ( http://www.doxygen.nl/ ).
I also saw CMS that create static HTML files, but hey are no longer maintained.