Set a localized slug also for the pages belonging to default language in Hugo - hugo

I have two languages defined on the Hugo site. By default, Hugo doesn't add a language prefix to the pages that belong to the default language.
In my case, I would also like to prefix the pages for the default language with the language prefix. And that would also require that pages of the default language to be generated into subfolder in public.
I would also like to avoid using aliases in markdown files.
Is this possible?

For prefix to the default language you need to add in your config.toml file one option:
defaultContentLanguageInSubdir = true
Render the default content language in subdir, e.g. content/en/. The site root / will then redirect to /en/.
Information from here - Configuration File Documentation
Output examples:
http://localhost:1313/about/ - without the option
http://localhost:1313/eu/about/ - with the option
But I do not know if it will satisfied your required about "subfolder in public".

Related

Share front matter between translations

I have a Hugo site with translations per file, using page bundles.
So the About page looks like this:
- about
- about-image.jpg
- index.en.md
- index.nl.md
- index.fr.md
The problem is that I have to repeat the non-i18n front matter in all of the .md files.
For example, date, tags, et cetera.
Is there a way in hugo to define the (basic) front matter once, and have translations only contain overrides needed for i18n?
You can define the default language in the config file of the site.
Then, you set the strings that do not need to be translated only into the translation file of the default language, and you do not define them in the other files.
As the translations are missing, Hugo will default to the default language (if defined in the config file).
https://gohugo.io/content-management/multilingual/#missing-translations
Hugo now brings with it front-matter cascade param which you can use to make descendant pages or even translation pages like
cascade:
- _target:
kind: page
lang: en
path: /blog/**
background: yosemite.jpg
- _target:
kind: section
background: goldenbridge.jpg
title: Blog
Learn more here https://gohugo.io/content-management/front-matter#front-matter-cascade

Drupal paths not taking i18n / Multilingual-ness into account?

I have i18n on my Drupal website. If I am currently on the "spanish" version of the site, and I have this code:
drupal_get_path_alias("node/171");
It returns
about-us
I was expecting it to return:
es/about-us
How do I make drupal_get_path_alias aware of languages? Or must I include the prefix myself manually each time?
the language prefix has nothing to do with the path-alias. You could for instance not use path-prefix to determin language, but a cookie. Or maybe evne a sub-domain, or a different tld.
The language-prefix simply has nothing to do with the path-alias

Use Flags instead of links for language switching?

Is there a way to use flags instead of the language shortcodes for the language switcher links in ImpressPages 4?
Unfortunately I wasn't able to find any information on this and am not really clear where that code is generated in the php files...
many thanks
Michael
You need to override default view file that prints language selection. In this case it's Ip/Internal/Config/view/languages.php
To do that you need to create a corresponding file in your theme's override directory. The path to the file should be like this - Theme/YOUR_THEME_NAME/Ip/Internal/Config/view/languages.php
More about view file and how to override them - http://www.impresspages.org/docs/view
Just copy the original view file to a new location and make any changes you like. And you'll be safe with system updates.

Dynamic locale name in multi-language site

I am developing an application in cakephp 2.3.4, Which is multi-language.
Admin can add any number of new languages.
My question is, When admin decides to add a new language, how resulting locale name should be defined.
Can a locale name be any arbitrary name, given by admin or it should be a dropdown containg all languages code according to language.
Unfortunately, your question is a bit 'vague', i.e., will administrators be able to add GNU-locale files (*.po), or are you talking about adding translations inside the database.
In any case, CakePHP uses locales according to the ISO 639-3 standard see here and here for more information. A complete list of those locales can be found inside the I10n class.
Since you probably also want to switch the locale of PHP itself when switching locales, so that, for example, date, money and time-formats will follow the right format for the locale, it's best to stick with those locales and not 'invent' your own locales.
See setlocale(). Be aware though, that PHP may use slightly different locale-codes than CakePHP uses. And it will depend on what locales are installed on your server.
To get a list of locales installed on your server, use locale -a on the command line. See this page for more information: https://wiki.archlinux.org/index.php/Locale
Which techniques to use for localization
A quick summary of techniques to use;
Short messages (interface/UI)
In general, locale files are used for short pieces of text. Locale-files are therefore mostly used for fixed strings,
for example, strings that are used in the interface (like 'are you sure you want to delete this file?' => 'weet u zeker dat u dit bestand wilt verwijderen?).
Longer (fixed) text
For longer pieces of text in your application, that are not part of the 'content' (not the blog-post, but for example a fixed page with a disclaimer),
it's best to use separate views for translated content, for example;
app/Views/MyController/disclaimer_eng.ctp
app/Views/MyController/disclaimer_deu.ctp
app/Views/MyController/disclaimer_fre.ctp
Content
For the content of your website (the part of your website that is managed by the 'user' of the website),
put translations inside the database. This data may be updated frequently and all translations should be updated as well.
How to implement this, is really up to you and depends on your situation. CakePHP offers a Translate behavior that you can use (http://book.cakephp.org/2.0/en/core-libraries/behaviors/translate.html), but in most of my situations that behavior didn't really fit our needs (IMO it is not very efficient, because it stores translations per-field, per-model).

How to setup Drupal multi language site?

I was searched and read many websites but can't find how to set up drupal multi language website.
I want to use 2 languages in a site.
These 2 languages have different content. (not content translation).
I had enabled Locale module, enabled multilingual support in each content type
but when i was added content in 2 languages
the front page list all of those articles without filter the site's language.
how to setup drupal 7 to list articles with filtered language.
eg:
http://example.com/en <- this url should list all english article.
http://example.com/fr <- this url should list all france article.
I have to install i18n or Internationalization module from Drupal contributed modules and enabled these option.
Multilingual select
Internationalization
** This module require Variable module.
Since the content is different, one way to achieve this is by creating two different content types. Assign an alias pattern to each content type like en/[node:title] and fr/[node:title]. You can then display each or both content types on any page; it could be a taxonomy page with alias en or fr. If you choose this method you won't need locale. This one is not intended for translated sites where each content has a matching translated content.
If you also want to expand some special words which have not include in language lib, you can try following code:
$zh = variable_get('locale_custom_strings_zh-hans');//zh-hans is your language key.
$zh["More news"] = '更多信息'; // KEY/VALUE
variable_set('locale_custom_strings_zh-hans',$zh); // set it back.

Resources