I have to build a multilingual website where you have to select your continent.
So you can choose America while your are in English but also America in Spanish. Europe in French, but also in English etc.
I have set language detection with path prefix on drupal 7. So my urls are like that domain.com/en/path-alias.
Some contents on my website will be hide for some continent but a lot of content will be the same so I dont want to do a multisite.
I wish to have urls like that domain.com/america/en/path-alias, domain.com/america/es/path-alias or domain.com/europe/fr/path-alias.
I don't find any solution to do that.
The module domain access looks cool but is not exactly what i want cause it works with subdomains while i want path prefix.
EDIT :
Ok i have found the solution of my problem in the drupal API.
This two hooks are exactly what i was looking for hook_url_inbound_alter, hook_url_outbound_alter
You should use this 2 hooks because in hook_url_inbound_alter(&$path, $original_path, $path_language) you tell Drupal what path should it display, and determine from received path that comes in $original_path (ex: region/lang/path) path that Drupal understands as a valid path (ex: lang/path) and override $path with it.
Next we need links from our pages to contain our custom path format, so we'll use hook_url_outbound_alter(&$path, &$options, $original_path) to convert all system paths or aliases generated with url() in your custom path format (generated path for url('lang/path')) will be region/lang/path. In $options array we can modify path prefix, or path language.
This worked for me but path alias dose not working now. This http://localhost/en/australia/node/376 should be http://localhost/en/australia/hotels-resorts
function mymodule_url_inbound_alter(&$path, $original_path, $path_language){
$cluster = 'australia';
$path = str_replace($cluster.'/','',$path);
}
function mymodule_url_outbound_alter(&$path, &$options, $original_path){
$cluster = 'australia';
$path = $cluster.'/'.($path);
$options['alias'] = true;
}
Related
I try to make my gatsby page multilingual.
I am using gatsby-plugin-react-i18next, i18next and react-i18next like in documentation.
i18n adds language prefix but page url is still the same. How i can translate friendly url?
i have: domain/es/hello-world
but i want: domain/es/hola-mundo
Is there a simple solution to this in GatsbyJS or is it more complicated?
I have found a solution to our problem. I have created a .json file with the original path and the one I want to change. For example: /es/contact/": "/es/contacto.
I create this file manually, and I add a path for each page that I want to change the path. Then, in the gataby-node file, I create the oncreatepage api (there is documentation for this api). In this function, I take the page parameter.
if page.path == to some .json file path, change the path to that of the .json file.
Thks for help. Finally i found perfect answer for my needs. gatsby-plugin-i18n-l10n have all i need for multilingual gatsby website with url translation too. I really recommend this module and I appreciate the work of the creators.
Here is link to github where you can find that plugin:
gatsby-plugin-i18n-l10n
I have the following problem. I want to rebrand the Chromium label to my own brand. I have tried this:
How to change Chromium browser logo and name?
so I have tried to replace all occurrences of "Chromium" or "Chrome" in the following files.
src/chrome/app/theme/chromium/BRANDING
src/chrome/app/generated_resources.grd
src/chrome/app/chromium_strings.grd
Now I need the browser to be in another language than English. Compiling the browser, some sections of the UI now have my new brand, but are still written in English, i.e. not translated. I suppose the reason is somewhere, that I have modified the .grd files as these are the template files for the translation. I have also looked into the associated .xtb files. There are the unique numerical ids for the translated string, and I think because I altered the occurences to my own brand in the template, the mapping between the string in the template and the translation in the .xtb file is corrupted.
How can I change the brand as suggested by Asesh in the link above and still have everything properly translated?
I have tried to modify the xtb files with my new brand name as well but the mapping did not work out between the id and the string in the template. I have read about GRIT but if I got it right, I cannot use the grit tool that comes with Chromium to just generate new numerical ids for the translations.
I know this sounds weird, but is it possible to use wildcard for theFileName parameter?
NSBundle.mainBundle().pathForResource(theFileName, ofType: "csv", inDirectory: directory)
Because I have several files that follow particular naming scheme. Basically, the first part of the filename is English and the second part is French. They are separated by three dashes. For example, "West---Ouest.csv". There is REST service the provides English part of the file name. However, it does not provide French. So what I like to do is use the English part and replace the french part with say asterisk. So, the value for filename parameter would be - "West---*". I tested asterisk, but seems that pathforresource does not work with that. Any work around to this problem?
Edit: English part is unique, so there's no file with the same english name.
No, there isn't. This is not a dynamically created file; you put it into your project by hand before building. Its name is absolutely known to you, and you must use its absolute name. Of course, you are free to change its name when you put it into your project. And if you have several files, you are free to form the name dynamically in code when your app runs — after all, theFileName can be created on the fly however you like. For example, in my app I have files called image1.jpg, image2.jpg, and so on, so I start with a number, form the name, and fetch the image.
Here are my example folders and documents
c:\b.odt
c:\myfolder
c:\myfolder\a.odt
I would like to create a hyperlink in a.odt that references b.odt
The direct path for the hyper link will look like this: c:\b.odt
However different people will have different paths. However, b.odt will always be in the same directory as myfolder.
I tried to use ./ but it wasn't working.
Is there a way I can make a hyperlink without the direct path?
https://forum.openoffice.org/en/forum/viewtopic.php?f=7&t=54592
Make sure you select the Document option in the Hyperlink dialog (as opposed to Internet. You may also have to preface with "file://" and/or apply the relative links setting in Options -> Load/Save -> General.
I can't understand the benefit(s) that I can get from Url.Content() method in ASP.NET MVC. For example, you see src='#Url.Content("~/Contents/Scripts/jQuery.js")'. Why should I use it? What reasons might exist for using it? What benefits, advantages, etc. over using plain old simple references like src='/scripts/jquery.js?
Update: Based on the answers, I'd like to know if there is any other reason for using it, other than handling virtual folders? Because I haven't seen using virtual applications that much (which of course doesn't mean that it hasn't been used that much).
Usually, your web application is published as: www.yoursite.com/. The ~ character matches the root of the site /.
However, if you publish your site withing a virtual directory www.yoursite.com/mywebapp/, the the ~ character would match "/mywebapp/".
Hard-coding Urls with "/" character would cause wrong page references.
Mapping virtual paths is it's only purpose.
If you do not ever need to map them and are sure your app or it folders will not sit under other apps then it won't serve you any purpose.
From the docs note if you don't use ~ you get no change in the result anyways:
"Remarks
If the specified content path does not start with the tilde (~) character, this method returns contentPath unchanged.
"
It is usefull if your applications root path is not the root path of your server. Url.Content("~/") returns the root folder of your application.