DeveloperBreeze

Bash: How to Loop Over Files in a Directory

bash
#!/bin/bash

for file in /path/to/directory/*; do
    echo "Processing $file"
    # perform some operation on $file
done

Continue Reading

Discover more amazing content handpicked just for you

Tutorial

How to Translate URLs in React (2025 Guide)

Update App.js:

import React from 'react';
import { useTranslation } from 'react-i18next';
import { BrowserRouter, Routes, Route, useNavigate } from 'react-router-dom';
import { routes } from './routes';
import './i18n';

const LanguageSwitcher = () => {
  const { i18n } = useTranslation();
  const navigate = useNavigate();

  const switchLang = (lang) => {
    const currentPath = window.location.pathname;
    const currentPage = currentPath.split('/')[1];

    i18n.changeLanguage(lang).then(() => {
      // Re-map path using new language
      const t = i18n.getFixedT(lang);
      const mappedRoutes = {
        en: { accueil: 'home', 'a-propos': 'about-us' },
        fr: { home: 'accueil', 'about-us': 'a-propos' },
      };

      const newPath = `/${mappedRoutes[lang][currentPage] || ''}`;
      navigate(newPath);
    });
  };

  return (
    <div className="lang-switch">
      <button onClick={() => switchLang('en')}>EN</button>
      <button onClick={() => switchLang('fr')}>FR</button>
    </div>
  );
};

const App = () => {
  const { t } = useTranslation();

  return (
    <BrowserRouter>
      <LanguageSwitcher />
      <Routes>
        {routes(t).map((route, idx) => (
          <Route key={idx} path={route.path} element={route.element} />
        ))}
      </Routes>
    </BrowserRouter>
  );
};

export default App;

May 04, 2025
Read More
Tutorial

Globalization in React (2025 Trends & Best Practices)

Globalization in web development is the process of designing and building applications that support multiple languages, regional settings, currencies, and cultural preferences — making your app ready for a global audience.

In 2025, React globalization goes beyond just i18n (internationalization). It includes:

May 04, 2025
Read More
Tutorial

Implementing Internationalization (i18n) in a Large React Application (2025 Guide)

{
  "welcome": "Bienvenue sur notre plateforme !",
  "language": "Langue",
  "date_example": "La date d'aujourd'hui est {{date, datetime}}",
  "price_example": "Prix : {{price, currency}}"
}

Edit src/index.js:

May 04, 2025
Read More
Tutorial

Building Micro-Frontends with Webpack Module Federation (2025 Guide)

cd app-shell
npx webpack serve

Visit http://localhost:8080 — you’ll see the React dashboard with the Vue analytics module seamlessly loaded via Module Federation.

May 04, 2025
Read More
Tutorial

State Management Beyond Redux: Using Zustand for Scalable React Apps

Getting started with Zustand is straightforward. Here's how you can integrate it into your React application:

   npm install zustand

May 03, 2025
Read More
Tutorial

Mastering React Rendering Performance with Memoization and Context

import React from 'react';

const Greeting = React.memo(function Greeting({ name }) {
  console.log("Greeting rendered");
  return <h3>Hello{name && ', '}{name}!</h3>;
});

In this example, Greeting will only re-render when the name prop changes. This optimization is particularly beneficial for components that render frequently with the same props.([React][4], [Content That Scales][5])

May 03, 2025
Read More
Code

How to Create a New MySQL User with Full Privileges

No preview available for this content.

May 01, 2025
Read More
Tutorial
javascript

Comparison and Logical Operators

// AND operator
console.log(true && true); // true
console.log(true && false); // false

// OR operator
console.log(false || true); // true
console.log(false || false); // false

// NOT operator
console.log(!true); // false
console.log(!false); // true

Use comparison and logical operators together for complex conditions.

Dec 11, 2024
Read More
Tutorial
javascript

Arithmetic Operators

  • Example:
  let result = 10 + 5 * 2; // 20
  // Multiplication happens before addition
  // 10 + (5 * 2) = 10 + 10 = 20

  let resultWithParentheses = (10 + 5) * 2; // 30
  // Parentheses alter the order
  // (10 + 5) * 2 = 15 * 2 = 30

Dec 11, 2024
Read More
Tutorial
javascript

Non-Primitive Data Types (Objects, Arrays, and Functions)

  delete person.isStudent;
  console.log(person);

Arrays are ordered collections of elements, which can be of any type.

Dec 11, 2024
Read More
Tutorial
javascript

Primitive Data Types

  • Syntax: Strings can be enclosed in single ('), double ("), or backticks (` ``).
  • Examples:
  let name = "Alice";
  let greeting = 'Hello';
  let message = `Welcome, ${name}!`; // Template literal
  console.log(message); // "Welcome, Alice!"

Dec 11, 2024
Read More
Tutorial
javascript

Variables and Constants

     const API_KEY = "12345";
     // API_KEY = "67890"; // Error: Assignment to constant variable
  • Variables are accessible only within the block they are declared in.
  • Example:

Dec 10, 2024
Read More
Tutorial
javascript

Hello World and Comments

  • What happens?
  • The console.log() function outputs text to the console.
  • "Hello, World!" is a string (text) enclosed in double quotes.
  • In a browser:
  • Open the console (Ctrl+Shift+J or Cmd+Option+J) and type the code.
  • In Node.js:
  • Save the code in a file (e.g., hello.js) and run it using:

Dec 10, 2024
Read More
Tutorial
javascript

Using Node.js to Run JavaScript

     npm -v
  • Open the terminal and type node to enter the Node.js interactive mode.
  • Type JavaScript directly:

Dec 10, 2024
Read More
Tutorial
javascript

Running JavaScript in the Browser Console

  • The console displays detailed error messages to help debug code.
  • Code written in the console is not saved.
  • Not suitable for large-scale projects or complex scripts.

Dec 10, 2024
Read More
Tutorial
javascript

Installing a Code Editor (e.g., VS Code)

To write and test JavaScript effectively, you need a code editor. While there are many options available, Visual Studio Code (VS Code) is one of the most popular choices due to its versatility and rich feature set.

Dec 10, 2024
Read More
Tutorial
javascript

JavaScript in Modern Web Development

  • Tools like React Native enable building native apps using JavaScript.
  • Example: Facebook's mobile app.
  • Frameworks like Electron allow creating cross-platform desktop apps.
  • Example: Visual Studio Code.

Dec 10, 2024
Read More
Tutorial
javascript

History and Evolution

  • Interpreted: Runs directly in the browser without requiring compilation.
  • Versatile: Works for front-end, back-end, and hybrid development.
  • Event-Driven: Handles user interactions dynamically.
  • Cross-Platform: Runs on any device with a browser.
  • Essential for web development.
  • Versatile for building web apps, mobile apps, and more.
  • Backed by a massive community and ecosystem.

Dec 10, 2024
Read More
Tutorial
javascript css +1

How to Create a Chrome Extension for Automating Tweets on X (Twitter)

- manifest.json
- background.js
- content.js
- popup.html
- popup.js

Each file has a specific role:

Dec 10, 2024
Read More
Tutorial
javascript

Advanced State Management in React Using Redux Toolkit

In src/app/store.js, enhance the store to support dynamic reducer injection:

import { configureStore, combineReducers } from '@reduxjs/toolkit';
import usersReducer from '../features/users/usersSlice';

const staticReducers = {
  users: usersReducer,
};

export const store = configureStore({
  reducer: staticReducers,
});

store.asyncReducers = { ...staticReducers };

export const injectReducer = (key, reducer) => {
  if (!store.asyncReducers[key]) {
    store.asyncReducers[key] = reducer;
    store.replaceReducer(combineReducers(store.asyncReducers));
  }
};

Dec 09, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!