what is general route rules in i18n - internationalization

I would like to separate my website to follow the Accept-Languages.
I have 4 language strings en, en-CA, zh-HK and zh-TW.
And my plan is routing them like /en, /en-CA, /zh-HK and /zh-TW.
but I have a question about that.
what is the general rule about routing?
for example, when I visit AWS website with /en-CA, I see 404 Not Found.
but I visit AWS with /ca, I can touch them.
Why AWS doesn't support /en-CA? or why it uses only /ca not both.
If there are some rules or protocol, let me know about it.
Thanks in advance.

Related

What do protofiles represent for googles API Linter?

since google did not create extensive documentation for their API Linter and I cannot find anything from other sources, i wanted to ask here.
From what exactly am i supposed to create protofiles and what do they represent?
As I understood, these protofiles get checked for compliance to their AIPs.
I'm interested in creating a automatic prototype (Java) to check for customized API Rules and am thinking about using Protobufer for this goal. Would this be a pragmatic solution?
Thank you!
As I now understand, Googles API Linter isn't supposed to check a API or a different API specification for compliance.
It checks proto files because they are themself the API specification and can be converted to Code. But before converting them they can be checked against rules they have to comply with.
These rules are not in the protofiles (as I initially thought) but in the many GO-files under rules/ .
Please correct me if you read this and find mistakes! Thanks!

Gorilla/Mux Reverse mapping URL

I'm new in development. Now trying to learn gorilla/mux router.
The question is about reversed urls.
In gorilla/mux I know we name them with .Name() method and access with .Url().
Could someone explain real use case of reserved URL's(Reverse mapping URL)?
But a few hours of googling didn't help me to find any info about that why we even need them? Will be really thankfull if you could show some practical examples.
Use cases if someone needs.
• Constructing redirects to send to a client - eg programmatically, so you don’t have to fix the URLs in your code elsewhere
• Building examples & tests
• Generating docs

VueJS SPA dynamic baseURL for axios

I've searched and searched and can't seem to find a pattern for this. I'd consider myself an intermediate Vue dev, however, the backend is my strong suit. I'm working on an app that will be white-labeled by resellers. While it's possible to have multiple builds, avoiding that would be ideal. The setup is a stand-alone vue-cli SPA connecting to a Laravel api backend and using the Sanctum auth package. So I need calls to the same domain. The issue: resellers will be on their own domain. The ask: Is there a pattern/solution for dynamically loading configs (mainly baseURL) for different domains (other items would by theme/stylesheet). Currently I have a few typical entries:
i.e. axios.defaults.baseURL = process.env.VUE_APP_API_BASE_URL
Basically, based on the domain the site is being served on, I'd like a dynamic/runtime config. I feel like this has been solved, but I can't seem to use the right search terms for some direction, so anything is helpful. I've tried a few things:
1) Parsing in js, but can't seem to get it to run early enough in the process to take effect? It seems to work, but I can't get it to "click"
2) Hit a public API endpoint with the current domain and get the config. Again, can implement, but can't seem to get it to inject into the Vue side correctly?
Any resources, pattern references or general guidance would be much appreciative to avoid maintaining multiple builds merely for a few variables. That said, I don't think there's much overhead in any of this, but also open to telling my I'm wrong and need multiple builds.
End Result
url visited is https://mydomaincom
then baseURL = https://api.mydomiancom
url visited https://resellerdomaincom
then baseURL=https://api.resellerdomaincom
I don't think there is a common pattern to solve your problem - I haven't found anything on the net.
The best software design solution could be the following:
have a single back-end
distribute only the client to your customers/resellers
Obviously the back end could see the domain of the application from which the request comes and manage the logic accordingly.
Good luck with your project.
Honestly how the question is put it's not really clear to me. Although my usual pattern is to:
Create an axios instance like so:
export const axiosInstance = axios.create({
// ...configs
baseURL: process.env.VUE_APP_URL_YOU_WOULD_LIKE_TO_HIT
})
and then whenever I make a request to some api, I would use this instance.
EDIT: According to your edit, you can either release the client to each customer, and have a .env file for each and every of them, or you can have a gateway system, where the client axios end point is always the same, hitting always the same server, and then from there the server decides what to ping, based on your own logic

Google Cloud and Go creating instances

thanks for looking at my post. i need to create an Linux instance with go lang and display the created public IP on the webpage.
Actually this is well hidden in the API docs.
First you need to get an Google Cloud SDK Client authenticated.
Then you might want to look at the following API operations:
https://godoc.org/google.golang.org/api/compute/v1#InstancesService.Insert
https://godoc.org/google.golang.org/api/compute/v1#Operation
https://godoc.org/google.golang.org/api/compute/v1#InstancesService.List
You should look at http://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/making-requests.html and then calling DescribeInstances (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html), should give you the public IP address.
Some pointers which may help here (haven't used these): https://gist.github.com/stephen-mw/9f289d724c4cfd3c88f2 and http://www.heystephenwood.com/search/label/aws
Hope this helps.

Url routing in elgg

I am trying to create a social network application using elgg.Since i am pretty new to elgg i like know whether i can define url routing like in cakePHP
I need the url like this
mydomain.com/username instead of mydomin.com/pg/profile/username
Is there any way that i can avoid /pg/ and /mod/ from the urls??
I am using elgg version 1.7.8.
I am not interested in url rewriting with .htaccess.
Thanks in advance
elgg itself is using .htaccess file to redirect /pg, /action etc. So, I think there is no other way than using .htaccess.
Elgg's page handling is pretty bad but you can register handlers as follows.
for /mypage:
elgg_register_page_handler('mypage', function($pages){
//content here
//the $pages parameter is an array. so /mypage/a/b with return
// array('a','b');
});
Matt Beckett has written a profile URL plugin (https://community.elgg.org/plugins/1091233) that, though for 1.8 and above, is only 35 lines of code and does exactly what you ask. You should be able to adapt this quite easily for 1.7.8.
He has also written a fuller page handler hijack plugin that may help if you have other use cases apart from user profiles - see https://community.elgg.org/plugins/854839
It is also only for 1.8 and above, however, and may take more effort to backport than the first.

Resources