Guest User

Strings Problem inside external JS/CSS file

a guest
Mar 26th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.39 KB | None | 0 0
  1. /*
  2.  * Problems: Some strings set in external js and CSS file, therefore we *couldn't* directly use lang() methods inside
  3.  * Troubleshoot proposal: see below
  4.  */
  5.  
  6. // Proposal for strings in JS:
  7.  
  8. <html>
  9. ...
  10.  
  11. // jQuery
  12. <script type="text/javascript" defer="defer" src="https://yukbisnis.com/applications/assets/js/jquery.js"></script>
  13.  
  14. // Define currently set language with php methods "get_language()", then use the variable to dynamically load
  15. // javascript function inside the external js file
  16. <script>var used_lang = '<?php get_language(); ?>'</script>
  17.  
  18. // All JavaScripts
  19. <script>...</script>
  20. <script>...</script>
  21. <script>...</script>
  22.  
  23. ...
  24. </html>
  25.  
  26.  
  27. // =====================================================================================================================
  28.  
  29.  
  30. // Proposal for strings in CSS (option 1):
  31. // * internal CSS
  32.  
  33. <html>
  34.     <head>
  35.         ...
  36.         <style>
  37.             #the_id::after {
  38.                 content: "<?= lang('STRING_KEYWORD'); ?>" ;
  39.             }
  40.         </style>
  41.     </head>
  42.     <body>
  43.         ...
  44.     </body>
  45. </html>
  46.  
  47. // Proposal for strings in CSS (option 2, may be not good idea):
  48. // using php methods to dynamically load which stylesheet file to be loaded. i.e:
  49. // <link media="all" rel="stylesheet" type="text/css" href="https://yukbisnis.com/.../<?php echo (get_lang() === 'en') ?  'en_style.css' : 'id_style.css'; ?>" />
Advertisement
Add Comment
Please, Sign In to add comment