Skip to content

Commit

Permalink
Support auto translate to english (#821)
Browse files Browse the repository at this point in the history
* Support auto translate to english

* docs: update code block syntax in encryption documentation to use PHP

* fix: update translation command in GitHub Actions workflow

* docs: update translation for cache documentation to improve clarity

* Update docs and translate

* ci: add dependency on translate-zh job for English translation

* docs: update wording for clarity in cache and fast-paginate documentation

* Update docs and translate

* ci: add git pull command before translation job

* ci: enhance translation workflow with environment setup and package installation

* ci: rename translation job from translate-zh to translate

* ci: reorder steps in translation workflow for clarity

* ci: implement retry logic and batch processing for translation

* docs: update comments in cache.md to provide Chinese translations

* docs: update cache.md for improved clarity in reference section

* Update docs and translate

---------

Co-authored-by: Deeka Wong <[email protected]>
Co-authored-by: huangdijia <[email protected]>
  • Loading branch information
3 people authored Dec 31, 2024
1 parent 317fd67 commit 6724c4f
Show file tree
Hide file tree
Showing 57 changed files with 564 additions and 317 deletions.
2 changes: 1 addition & 1 deletion en/components/amqp-job.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Introduction

`friendsofhyperf/amqp-job` is an asynchronous task component based on the `hyperf/amqp` component. It supports dispatching tasks to an AMQP service, which are then consumed by consumers. By encapsulating the `hyperf/amqp` component, it provides a more convenient way to dispatch and consume tasks.
`friendsofhyperf/amqp-job` is an asynchronous task component based on the `hyperf/amqp` component, which supports dispatching tasks to the AMQP service and then consuming them via consumers. It encapsulates the `hyperf/amqp` component, providing a more convenient way to dispatch and consume tasks.

## Installation

Expand Down
14 changes: 7 additions & 7 deletions en/components/cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ composer require friendsofhyperf/cache

## Usage

### Annotations
### Annotation

```php
namespace App\Controller;
Expand All @@ -29,7 +29,7 @@ class IndexController
public function index()
{
return $this->cache->remember($key, $ttl=60, function() {
// return sth
// Return value
});
}
}
Expand All @@ -41,7 +41,7 @@ class IndexController
use FriendsOfHyperf\Cache\Facade\Cache;

Cache::remember($key, $ttl=60, function() {
// return sth
// Return value
});
```

Expand All @@ -52,14 +52,14 @@ use FriendsOfHyperf\Cache\Facade\Cache;
use FriendsOfHyperf\Cache\CacheManager;

Cache::store('co')->remember($key, $ttl=60, function() {
// return sth
// Return value
});

di(CacheManager::class)->store('co')->remember($key, $ttl=60, function() {
// return sth
// Return value
});
```

## References
## Reference

Like [Laravel-Cache](https://laravel.com/docs/8.x/cache)
For more information, please refer to [Laravel-Cache](https://laravel.com/docs/8.x/cache)
4 changes: 2 additions & 2 deletions en/components/command-signals.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Command Signals

Signal handling component for Hyperf Command.
Hyperf Command Signal Handling Component.

## Installation

Expand Down Expand Up @@ -47,7 +47,7 @@ class FooCommand extends HyperfCommand
}
```

## Running
## Execution

- `Ctrl + C`

Expand Down
4 changes: 2 additions & 2 deletions en/components/command-validation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Command Validation

A validation component for Hyperf command line.
A validation component for Hyperf command-line applications.

## Installation

Expand All @@ -27,7 +27,7 @@ class FooCommand extends HyperfCommand
use ValidatesInput;

/**
* The command line to execute
* The command line to be executed.
*/
protected string $name = 'foo:hello {?name : The name of the person to greet.}';

Expand Down
24 changes: 12 additions & 12 deletions en/components/compoships.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Compoships

**Compoships** provides the ability to define relationships based on two (or more) columns in Hyperf's Model ORM. When dealing with third-party or pre-existing schemas/databases, there is often a need to match multiple columns in the definition of Eloquent relationships.
**Compoships** provides the ability to specify relationships based on two (or more) columns in Hyperf's Model ORM. This is particularly useful when dealing with third-party or pre-existing schemas/databases where you need to match multiple columns in the definition of Eloquent relationships.

## Problem
## The Problem

Eloquent does not support composite keys. Therefore, it is not possible to define relationships from one model to another by matching multiple columns. Attempting to use `where` clauses (as shown in the example below) does not work when eager loading relationships because **$this->team_id** is null when handling the relationship.
Eloquent does not support composite keys. Therefore, it is not possible to define a relationship from one model to another by matching multiple columns. Attempting to use a `where` clause (as shown in the example below) does not work when eager loading relationships because **$this->team_id** is null when the relationship is being processed.

```php
namespace App;
Expand All @@ -23,7 +23,7 @@ class User extends Model

## Installation

It is recommended to install the **Compoships** component using [Composer](http://getcomposer.org/).
It is recommended to install **Compoships** via [Composer](http://getcomposer.org/).

```shell
composer require friendsofhyperf/compoships
Expand All @@ -33,17 +33,17 @@ composer require friendsofhyperf/compoships

### Using the `FriendsOfHyperf\Compoships\Database\Eloquent\Model` Class

Simply have your model classes extend the `FriendsOfHyperf\Compoships\Database\Eloquent\Model` base class. `FriendsOfHyperf\Compoships\Database\Eloquent\Model` extends the `Eloquent` base class without altering its core functionality.
Simply have your model class extend the `FriendsOfHyperf\Compoships\Database\Eloquent\Model` base class. `FriendsOfHyperf\Compoships\Database\Eloquent\Model` extends the `Eloquent` base class without altering its core functionality.

### Using the `FriendsOfHyperf\Compoships\Compoships` Trait

If for some reason you cannot extend `FriendsOfHyperf\Compoships\Database\Eloquent\Model` in your model, you can use the `FriendsOfHyperf\Compoships\Compoships` trait. Simply use this trait in your model.
If for some reason you cannot extend your model from `FriendsOfHyperf\Compoships\Database\Eloquent\Model`, you can utilize the `FriendsOfHyperf\Compoships\Compoships` trait. Just use the trait in your model.

**Note:** To define a multi-column relationship from model *A* to another model *B*, **both models must extend `FriendsOfHyperf\Compoships\Database\Eloquent\Model` or use the `FriendsOfHyperf\Compoships\Compoships` trait**

### Usage

... Now we can define relationships from model *A* to another model *B* by matching two or more columns (by passing an array of columns instead of a string).
... Now we can define a relationship from model *A* to another model *B* by matching two or more columns (by passing an array of columns instead of a string).

```php
namespace App;
Expand All @@ -61,7 +61,7 @@ class A extends Model
}
```

We can use the same syntax to define the inverse relationship:
We can use the same syntax to define the inverse of the relationship:

```php
namespace App;
Expand All @@ -81,15 +81,15 @@ class B extends Model

### Example

As an example, suppose we have a task list with categories, managed by multiple user teams, where:
As an example, let's assume we have a task list with categories, managed by multiple user teams, where:

- A task belongs to a category
- A task is assigned to a team
- A team has many users
- A user belongs to a team
- A user is responsible for a category's tasks
- A user is responsible for tasks in a category

The user responsible for a specific task is the currently responsible user for that category within the team.
The user responsible for a specific task is the user currently responsible for that category within the assigned team.

```php
namespace App;
Expand All @@ -107,7 +107,7 @@ class User extends Model
}
```

The same syntax can be used to define the inverse relationship:
The same syntax can be used to define the inverse of the relationship:

```php
namespace App;
Expand Down
8 changes: 4 additions & 4 deletions en/components/confd.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Confd

Configuration management component for Hyperf.
Hyperf's configuration management component.

## Installation

Expand All @@ -13,13 +13,13 @@ composer require friendsofhyperf/nacos

## Commands

Fetch configuration from `etcd/nacos` and update `.env`.
Fetch configurations from `etcd/nacos` and update `.env`.

```shell
php bin/hyperf.php confd:env
```

## Define Listener
## Defining Listeners

```php
<?php
Expand Down Expand Up @@ -53,7 +53,7 @@ class ConfigChangedListener implements ListenerInterface
}
```

## Support
## Supported

- [x] Etcd
- [x] Nacos
Expand Down
2 changes: 1 addition & 1 deletion en/components/config-consul.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Config Consul

Consul configuration component for Hyperf.
A Consul configuration component for Hyperf.

## Installation

Expand Down
4 changes: 2 additions & 2 deletions en/components/console-spinner.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Console Spinner

A progress bar component provided for the Hyperf framework.
A progress bar component for the Hyperf framework.

## Installation

Expand Down Expand Up @@ -37,7 +37,7 @@ class FooCommand extends Command
}
```

`$spinner` is compatible with Symfony ProgressBar, so you can run any methods from this class. Alternatively, you can use the `withSpinner` method by providing an iterable object.
The `$spinner` is compatible with Symfony ProgressBar, so you can run any method of this class. Alternatively, you can also use the `withSpinner` method by providing an iterable object.

```php
$this->withSpinner(User::all(), function($user) {
Expand Down
4 changes: 2 additions & 2 deletions en/components/di-plus.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DI Plus

A dependency injection enhancement component for Hyperf.
Enhanced Dependency Injection Component for Hyperf.

## Installation

Expand Down Expand Up @@ -38,7 +38,7 @@ class Foo2
}
```

Supports annotation-based configuration
Supports annotation-based injection

```php
<?php
Expand Down
2 changes: 1 addition & 1 deletion en/components/elasticsearch.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Elasticsearch

A client component for Elasticsearch customized for Hyperf.
A customized Elasticsearch client component for Hyperf.

## Installation

Expand Down
24 changes: 12 additions & 12 deletions en/components/fast-paginate.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
## About

This is a fast `limit`/`offset` pagination macro for Hyperf. It serves as a replacement for the standard `paginate` method.
This is a fast `limit`/`offset` pagination macro for Hyperf. It can replace the standard `paginate` method.

This package utilizes a SQL technique similar to deferred joins to achieve speed improvements. Deferred joins are a technique where the requested columns are accessed only after applying `offset` and `limit`.
This package uses an SQL approach similar to "deferred joins" to achieve this speedup. Deferred joins are a technique where the requested columns are accessed only after applying the `offset` and `limit`.

In our implementation, we are not actually performing a join, but instead using a `where in` clause with a subquery. With this approach, we create a subquery optimized by a specific index for maximum performance, and then use these results to retrieve the full rows.
In our case, we don't actually perform a join but use a `where in` with a subquery. Using this technique, we create a subquery that can be optimized with a specific index for maximum speed, and then use these results to fetch the full rows.

The SQL query looks like this:
The SQL statement looks like this:

```sql
select * from contacts -- The full data that you want to show your users.
Expand All @@ -20,28 +20,28 @@ select * from contacts -- The full data that you want to show your
)
```

> When running the query above, you might encounter errors! For example, `This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery.`
> In this package, we run these as [two separate queries](https://github.com/hammerstonedev/fast-paginate/blob/154da286f8160a9e75e64e8025b0da682aa2ba23/src/BuilderMixin.php#L62-L79) to mitigate this problem!
> When running the above query, you might encounter an error! For example, `This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery.`
> In this package, we run them as [two separate queries](https://github.com/hammerstonedev/fast-paginate/blob/154da286f8160a9e75e64e8025b0da682aa2ba23/src/BuilderMixin.php#L62-L79) to solve this issue!
Depending on your dataset, the performance improvement may vary, but this approach allows the database to inspect as little data as possible to fulfill the user's request.
Depending on your dataset, the performance improvement may vary, but this approach allows the database to examine as little data as possible to meet the user's needs.

While this method is unlikely to perform worse than traditional `offset`/`limit`, it is still a possibility, so be sure to test on your dataset!
While this method is unlikely to perform worse than the traditional `offset` / `limit`, it is possible, so be sure to test it on your data!

> If you'd like to read a 3,000-word article on the theory behind this package, visit [aaronfrancis.com/2022/efficient-pagination-using-deferred-joins](https://aaronfrancis.com/2022/efficient-pagination-using-deferred-joins).
> If you want to read a 3,000-word article on the theory behind this package, visit [aaronfrancis.com/2022/efficient-pagination-using-deferred-joins](https://aaronfrancis.com/2022/efficient-pagination-using-deferred-joins).
## Installation

```shell
composer require friendsofhyperf/fast-paginate
```

No further steps are required. The service provider will be automatically loaded by Hyperf.
No additional steps are required; the service provider will be automatically loaded by Hyperf.

## Usage

Wherever you would use `Model::query()->paginate()`, you can use `Model::query()->fastPaginate()` instead! It's that simple! The method signature is the same.
Anywhere you would use `Model::query()->paginate()`, you can use `Model::query()->fastPaginate()`! It's that simple! The method signature is the same.

Relationships are also supported:
Relations are also supported:

```php
User::first()->posts()->fastPaginate();
Expand Down
2 changes: 1 addition & 1 deletion en/components/grpc-validation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Grpc Validation

GRPC validation component for Hyperf.
A GRPC validation component for Hyperf.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion en/components/http-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ use FriendsOfHyperf\Http\Client\Http;
$response = Http::get('https://example.com');
```

## Reference Documentation
## Documentation

For more information, please refer to the [Laravel HTTP Client Documentation](https://laravel.com/docs/9.x/http-client).
4 changes: 2 additions & 2 deletions en/components/http-logger.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Http Logger

An HTTP logging component provided for Hyperf.
An HTTP logging component for Hyperf.

## Installation

```shell
composer require "friendsofhyperf/http-logger"
composer require "friendsofhyperf/http-logger
```
## Publish Configuration
Expand Down
6 changes: 3 additions & 3 deletions en/components/ide-helper.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# IDE Helper

The IDE helper component for Hyperf
The IDE Helper component for Hyperf

## Installation

Expand All @@ -10,13 +10,13 @@ composer require friendsofhyperf/ide-helper

## Usage

- Generate model helpers
- Generate Model Helper

```shell
php ./bin/hyperf.php ide-helper:model
```

- Generate macro helpers
- Generate Macro Helper

```shell
php ./bin/hyperf.php ide-helper:macro
Expand Down
2 changes: 1 addition & 1 deletion en/components/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Components

👈 Please check the menu on the left and select a component.
👈 Please refer to the menu on the left to select components
2 changes: 1 addition & 1 deletion en/components/ipc-broadcaster.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ipc Broadcaster

The Hyperf process communication broadcaster component.
Hyperf Inter-Process Communication Broadcast Component.

## Installation

Expand Down
Loading

0 comments on commit 6724c4f

Please sign in to comment.