Hugo : How to translate group name in URLs - internationalization

I'm struggling with something that is probably simple.
I created a new page type under layouts:
layouts
|--- PageType
|--- list.html
|--- single.html
Under content I have the following structure:
content
|--- English
|--- PageType
|--- first.md
|--- second.md
|--- French
|--- PageType
|--- first.md
|--- second.md
Up to this point all works great. Now when it comes to i18n, I know I can use slug font matter in the *.md files, but how do I change the PageType that appears in the translated URL?
English:
http://localhost:1111/PageType/
http://localhost:1111/PageType/first/
French (not what I want):
http://localhost:1111/fr/PageType/
http://localhost:1111/fr/PageType/premier/
Desired French:
http://localhost:1111/fr/TypeDePage/
http://localhost:1111/fr/TypeDePage/premier/

Related

Laravel nWidart/laravel-modules, move an existing module to another folder

I have a bunch of modules in Modules folder. For example "Modules/Customers"
And I need to move everything to "Modules/Core/Customers" keeping all the functionality working. Besides I must will use another subfolder for some modules:
Modules
|___ Core
| |__ Customers
| |__ Products
|
|___ External
|__ Taller
I suppose there might be three possibilities:
1- Lucky one: automatically with an artisan command, but I did not find anything on documentation (https://docs.laravelmodules.com/)
2- Manually changing files and configs, but I suppose that will leave namespaces unchanged, and that is not acceptable I would say.
3- Worst but likely: manually changing namespaces and config files.
I went for the third one as #lk77 suggested and everything was correct if I changed the folder for modules in config file module.php, except that then I cannot add several paths (or I don not find the way as it does not seem to be an array) or a more generic Modules/* as path.
'paths' => [
/*
|--------------------------------------------------------------------------
| Modules path
|--------------------------------------------------------------------------
|
| This path used for save the generated module. This path also will be added
| automatically to list of scanned folders.
|
*/
'modules' => base_path('Modules/Core'),
Thanks a lot!!
Thanks very much
Here is what I finally did. For the existing modules created previously in "Modules":
1- Move files to Modules/Core folder and change manually all references to "Modules/" for "Modules/Core" in folders "app", "bootstrap" and "Modules" (with help of replace all from sublime :-) ). Afterwards it was necessary to manually change references in files "composer.json" and "module.json" of each module.
2- In config/modules.php activate scan:
'scan' => [
'enabled' => true,
'paths' => [
base_path('Modules/Core'),
base_path('Modules/External'),
base_path('vendor/*/*'),
],
],
After doing this old modules seemed to be working properly, but trying to include new ones triggered errors.
In fact the versions that included the feature to add the possibility for managing submodules/subfolders were retired shortly after the release.
So, finally I guess it is better not to use this approach with the package due to the problems.
In the end we are going to use subfolders in Laravel default tree for the core modules and use the package laravel-modules for external and optional custom modules:
app
|
|--- Http
| |
| |--- Controllers
| . |
| . |--- Customers
| |--- Products
|
|--- Models
. |
. |--- Customers
. |--- Products
.
.
Modules
|--- Taller
.
.
.

Run go tests except from one package

I’ve the following project structure and I want to run go test exclude option to run the test
e.g. Command to Run all tests except the test in the cmd package (I’ve more then 3 packages , the struct below is a simple example)
myGithubProject/
|---- cmd
|---- -command
|---- -hello.go
|---- -hello_test.go
|---- internal
|---- -fs.go
|---- -fs.go
|---- -fs_test.go
|---- -log
|---- -log.go
|---- -log_test.go
main.go
If you have a hierarchy like that, you may specify the sibling folder to test (and recurse down) like this:
go test internal/...
If this is not feasible to you (e.g. you have many siblings of cmd, or you have many subfolders inside cmd which you do want to test), you may use build constraints to achieve what you want.
For example, add an exclusion of a donttestme build tag to the hello_test.go file (the first line):
// +build !donttestme
And then when you specify this tag when testing, files that exclude this build tag will not be considered (will be skipped):
go test -tags donttestme <somepackages>

Override an existing Blade directive

I'm building a system that implements an inherited template system using Blade. Depending on where the user is, a different view will be loaded.
The system works well, where I have a default 'theme', which contains all views and components for everything the website uses. I don't use the default view method in my controllers, I instead use my own function which works in the same way as view but instead attempts to load the view in the lowest part of the hierarchy and then works its way up until it lands on the default.
For example, my view structure looks like:
+-- views
| +-- frontend
| +-- default
| +-- home.blade.php
| +-- test.blade.php
| +-- site1
| +-- en-gb
| +-- home.blade.php
| +-- en-de
| +-- home.blade.php
| +-- site2
| +-- en-gb
| +-- home.blade.php
This works well. I can call custom_view('home'); and based on certain circumstances the correct view will be shown. In the above example if I call custom_view('test') my system will check the correct folder for the site and locale, and if the view doesn't exist then the default fallback will be used.
My problem comes when I want to use Laravel directives for loading view partials in my code. The three directives that are troublesome are:
#each(), #include() and #component().
I would like to override these directives and have them look up the file from the appropriate sub-directory in my view structure first.
How can I override Blade directives?

wget page-requisites in a different folder?

I'm using wget to download an HTML page with all its requisites. I would like to know if is it possible to download the page requisites (css, images, scripts, etc) in a different folder than the html page.
For example, right now if the html page has a link like the following one:
<link href="/css/style.css" rel="stylesheet">
The result from wget folder structure looks like:
├── index.html
├── css
├── style.css
Is there any option to change the style's output folder name? Like so:
├── index.html
├── **another name**
├── style.css
Thank you so much!

How can I create a clean tag library (.jar) containing custom tags and composite components in JSF 2.2?

I've read the various blog posts and stackoverflow posts on how to create a composite components and custom tags within a web app and have gotten things to work just fine. I'm now trying to move everything into a reusable JAR file.
mylib.jar hierarchy:
src/main/java
com.example.MyComposite.java
src/main/resources/
META-INF
faces-config.xml
my.taglib.xml
META-INF/resources/components
myComposite.xhtml
META-INF/tags
myTag.xhtml
my.taglib.xml:
<facelet-taglib version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facelettaglibrary_2_2.xsd">
<namespace>http://www.example.com/components</namespace>
<tag>
<tag-name>myTag</tag-name>
<source>
tags/myTag.xhtml
</source>
</tag>
<tag>
<tag-name>myComposite</tag-name>
<component>
<resource-id>
components/myComposite.xhtml
</resource-id>
</component>
</tag>
</facelet-taglib>
I've built this as a jar and used it in my web-app and both the custom tag and composite component work great. It took me trying 100 different combinations of hierarchy to get it to work though.
My problem is that I don't like how I seem to have to put custom tags in one place (/tags) and composite components in another (/resources/components). In addition, I have to reference custom tags with the source tag and composite components with a component/resource-id tag. For example, I tried putting the myTag.xhtml into /resources/components and referencing it with a resource-id but I got NPE's when I tried to use it.
So do tags and components have to be in different directories? Do I just have to live with this hierarchy?
You can use <composite-library-name> alone for composites to reduce unnecessary <tag> boilerplate for composites. As to tagfiles, you could just put them in /resources/tags and alter <source> accordingly so the folder structure is more uniform.
src/main/java
`-- com/example/MyComposite.java
src/main/resources
`-- META-INF
|-- resources
| |-- components
| | `-- myComposite.xhtml
| `-- tags
| `-- myTag.xhtml
|-- faces-config.xml
`-- my.taglib.xml
<facelet-taglib version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facelettaglibrary_2_2.xsd">
<namespace>http://www.example.com/components</namespace>
<composite-library-name>components</composite-library-name>
<tag>
<tag-name>myTag</tag-name>
<source>resources/tags/myTag.xhtml</source>
</tag>
</facelet-taglib>
See also:
Change composite-component's namespace

Resources