how to toggle between a multiple English and Arabic in my website? [duplicate] - html

This question already has answers here:
How to make a Multilanguage website [closed]
(3 answers)
Closed 2 years ago.
I'm a junior front-end developer based in Egypt, so most of what I work on will be in Arabic but I will also need to support English since it is the standard website language used.
I'm looking for a solution to help my clients toggle between multiple languages. Should I build an entire project twice or what is their a better solution to switch languages on a wbeite?
Please keep in mind that I'm still a junior developer with just 2 years of experience.

You can declare the language of websites in the <html> tag, e.g. <html lang="en">. Therefore, you should be able to save your original website/project in one language and then save another copy of your website/project with the other language you'd like to show.
Read more about declaring languages in HTML
If you want to do all of this on one page only, you can use JavaScript to change the page's language using an onclick function. MDN has a good tutorial using onclick here. However, this is more complicated since you'll need to use a dictionary, such as Google's Cloud Translation API.

Related

How to let robots parse our custom html elements? [duplicate]

This question already has answers here:
How do search engines deal with AngularJS applications?
(15 answers)
Closed 6 years ago.
I have a website containing custom elements (i use angular 2), and google fails to parse them correctly :
It only sees
<my-app></my-app>
It seems that the value of this component is not retrieved at all by google robots.
Is there a best practice / workaround ?
Thanks for your help.
This has been asked a million times. Please refer to this question and this specific page by google.
Times have changed. Today, as long as you're not blocking Googlebot from crawling your JavaScript or CSS files, we are generally able to render and understand your web pages like modern browsers. To reflect this improvement, we recently updated our technical Webmaster Guidelines to recommend against disallowing Googlebot from crawling your site's CSS or JS files.
What you can do is getting the HTML of your rendered page and inserting it into the <my-app></my-app> tags without user information or the like.
This will get replaced anyway after Angular has booted up, this means you can even put something completely different in there.

How does one change the language of an HTML page? [duplicate]

This question already has answers here:
How to specify language of website? (HTML?)
(3 answers)
Closed 2 years ago.
Specifically, I am writing in AMP HTML, if there would be any conflictions.
I would like to approach a pretty cool concept of being able to change the language of an HTML page I am working on, just by the click of a button, like so:
<button>Parlez-vous Français?</button>
I would like the person do be able to click a button that would specifically translate the page into French. But it would be cool to add some animation to it too, like maybe a fade-out/fade-in sort of thing.
How would I be able to approach this?
You can simply change it in the HTML tag itself
<html lang="fr">
...
</html>
considering you know that it's an html attribute. There are many ways you can change it. Storing the change can either be on database or session storage. Hope this helps

Change Code in multiple HTML files [duplicate]

This question already has answers here:
What are the new frames? [closed]
(3 answers)
Closed 8 years ago.
Is there a way I can change code in multiple static HTML files? I just added two new pages to the site, and the side bar containing links to all the pages need to be updated in all files. Is there a easy way to do it? Thank you very much.
Update: Also the side bar has an active row, which should be different in each file, is there a easy way to change that in each file as well?
notepad ++ allows you to search and replace and also has a reg-ex search and replace function you can use to replace all or replace via file extensions
The question you are asking has two good answers.
The first simple answer for your level of HTML knowledge would be to use a text-editors Find & Replace functionality to simply change identical pieces of code so all pages match. This would be the simplest answer for your question.
The larger answer would be to introduce you to the idea of a layout file. With this layout file(s) you could define your entire page layout, links, headers, etc. Then with each page you load you simply call the content you want to show inside the layout file. This is a high level concept and should ultimately be your goal to reduce issues like those which you stated in your question.
You can accomplish this with a variety of technologies such as PHP, ASP.Net, or Java EE development which are all very advanced stacks. The best starting point I would suggest is Server Side Includes. This will allow you to simply call the required layout text. While this solution is rather legacy; it might help you accomplish your task with grater efficiency.
Microsoft Visual Studio Express can find and replace in files.
But maybe it's time to refactor your pages and put the common information in a distinct file.

How to detect an Operating System [duplicate]

This question already has answers here:
Cross Browser Flash Detection in Javascript
(16 answers)
Closed 9 years ago.
I am in the process of trying to rewrite my website, and I have limited experience in HTML/CSS/Javascript. It is a photography website using galleries. I am wanting to make the default view to be using Flash, but I know that iPad/iPhone etc do not support Flash. I am looking for a way to determine what the OS is so I can direct the iWhatevers (and others if there are any), to a purely HTML site, and the non-iWhatevers to the Flash site.
I presume it would be done in the Heading part of the HTML, but what script would I use to do this?
Thank you in advance...
That sounds like a lot of extra work to create to maintain a Flash and a regular HTML site when a properly done HTML5 site can kill all the browsers with one stone. Consider a CMS like WordPress if you are not comfortable with a lot of coding.
However, if you want to go the route you mentioned, this thread will show you how: Detect if device is iOS

How to embed PDF in a web page without javascript [duplicate]

This question already has answers here:
Recommended way to embed PDF in HTML?
(30 answers)
Closed 9 years ago.
I want to show pdfs in certain pages on my site. I've experimented with google's viewer api and it works great but I dont want to depend on a third party api call. I also want it to be as robust and reliable as possible, so I'm trying to avoid javascript. I see some indication that it can be done with just HTML using either or tags, but there appears to be disagreement as to the browser support: Recommended way to embed PDF in HTML?
Is there a definitive way to do this?
I need to support IE8+ and the site will be responsive, so the solution has to be able to accommodate smaller screen sizes.
Attention duplicate police: The entire basis for this question is to figure out what is specifically NOT answered in the other question. I even linked to that question in my ow
If you don't want to use JavaScript -- no, there is not.
Even if there is a good enough solution for some OS with something like Acrobat Reader installed (maybe you get lucky with Windows), all the other OSes still don't support it.
So, if you want your site to be seen more or less the same way by everybody, you'll have to go with Javascript base things and their not so robust and reliable support -- they are pretty portable, that's a great thing on the web.
Related:
Open Source Javascript PDF viewer
Why Use a Javascript PDF Viewer